I have been watching the “The new UI” tutorial (Recorded Video Sessions on UI - Unity Learn) and in that, around 19:40, the teacher is having a slider and text and shows how to present the slider value in the text object, to which he create/attach a script with the following code:
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class UpdateValue : MonoBehaviour {
public Text text;
public void UpdateText(float f) {
text.text = f.ToString ();
}
}
He then goes back into Unity and run the scene and as he moves the slider the text value change. I just do not get it to work. I do not fully understand how the slider communicate with the text object as the script is attached to the text object.
He also show another way by defining the Slider in the script but for some reason i do not get that to work either.
I have tested this in my current project as well as, lately, in an empty project but just do not get it.
Anyone that can share some light on this or/and point to other sources of information on this topic.