![]() On this script you setup the gameobjects. Then have a script that controls which game objects are active when the value on the slider changes. I am trying to modify my gameobject (and a text that goes with each of them) everytime the slider hits a new value. I haven’t tested this code, its just a example, but I hope you can see the idea behind it and change the code around until it works for you and your project. I want to use a UI slider in Unity for my AR project. Positions for the object, so I just put in some values, that you need to change.īut as you pull the slider in any direction, the 3d object should also slide between these two vectors. ![]() So, I setup the slider GUI object to slide between 0.0 and 1.0.Īnd I use this value to Lerp the position of the 3d object. M_ = Vector3.Lerp(m_offPosition, m_onPosition, m_currentValue) M_currentValue = GUI.VerticalSlider(position, m_currentValue, m_topValue, m_bottomValue) Slider goes between 0.0 and 1.0, or you can see it as 0% to 100% Public GameObject m_3dObjectSlider = null Private Vector3 m_onPosition = new Vector(1.0f, 1.0f, 1.0f) Private Vector3 m_offPosition = new Vector(0.0f, 0.0f, 0.0f) I have little problem reading the script code, but here is a simple example on how you can do it: private float m_currentValue = 0.0f MyAnimation = animation ĪmtToMove =buttonsGUI. VSliderValue = GUI.VerticalSlider(Rect (887.5, 10, 50, 203), vSliderValue, -1500.0, -100.0,vsliderStyle,vthumbStyle) Īnd this is my other Script for the 3D object to be interact with my GUI Slider. I’m trying to get to work my script, but I can’t. I made one script for the GUI buttons with a Slider and other for the 3d Object “VariableSpeedAdjuster” and finally another for the rotor or motor. I made one button to activated the drill so you can see the tool spinning and a slider to control the speed in the GUI.īut I have problems trying to synchronize a GUI slider with a 3d Object “VariableSpeedAdjuster” with animation attached, so when the GUI slider is moving the 3d object too. ![]() I’m trying to make a Drill with some interactive buttons as exercise to learn Unity.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |