I have just started using the Mixed Reality Toolkit (former Holotoolkit) and I am trying to use a slider.
So I made a scene with a 3DTextPrefab, a Button and a Slider. I wrote a script and attach it to the 3DTextPrefab. This script is
public class Clicker : MonoBehaviour {
public GameObject ObjectToShow;
public float waitTime;
private void Awake()
{
ObjectToShow.SetActive(false);
}
public void Click()
{
TextMesh tm = ObjectToShow.GetComponent("TextMesh") as TextMesh;
tm.text = "Hello with parameter" + waitTime;
ObjectToShow.SetActive(true);
StartCoroutine(HideAfterTimeout());
}
public void setWaitTime(float t)
{
waitTime = t;
}
IEnumerator HideAfterTimeout()
{
// yield return new WaitForSeconds(0.1f);
yield return new WaitForSeconds(waitTime);
ObjectToShow.SetActive(false);
}
}
In the button, there is the "Interactive" script (by default), so I added the 3dTextPrefab as an object to the OnSelectedEvents
list and selected its Click
function.
Doing this every time I click on the button, it calls the click function of the Prefab script. So far so goo.
I tried to do something similar with the slider so I added the prefab as an object to the Slider Gesture Control
script's OnUpdateEvent
and selected its setWaitTime
function.
My problem is, the setWaitTime
function has a parameter and I can see that in the inspector. This parameter has to be the actual value of the slider.
How do you get the actual value of the slider to put it there?