- Home /
How to set and get value to and from scrollbar using textfield value?
I want to have one textfield which is able to set and get value to and form scrollbar. Here is my code:
using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour
{
private float scrolledVal;
private float temVal;
void OnGUI()
{
scrolledVal = GUI.HorizontalScrollbar (new Rect(20, 20, 100, 30), scrolledVal, 1.0F, 33f, 58f);
scrolledVal = float.Parse(GUI.TextField (new Rect(130, 20, 50, 20), scrolledVal.ToString()));
}
}
That I can only get the value from scrollbar, but I cannot set value scrolled to scrollbar. Please help.
capture.png
(2.0 kB)
Comment
Answer by Kiwasi · Dec 15, 2014 at 06:13 AM
Are you version constrained? If not I would upgrade to the newest version of Unity. The UI tools introduced in 4.6 make this trivial.
I think you are looking for something like Single.Parse
Your answer
Follow this Question
Related Questions
How to make Scrollable Label in NGUI. 0 Answers
Cloud recognition in Vuforia 0 Answers
Unity 3D connection to (MS)SQL server 3 Answers