I am new to unity & trying to make small POC in MRTK. As a part of POC, I need to hide the Object when the button is clicked. Once Button is clicked it updates the current position of the Cube and should hide the Sphere. Position logic is working. But Error is displayed when trying to hide Sphere.
- UnassignedReferenceException: The variable sph of ButtonBehaviour has not been assigned. You probably need to assign the sph variable of the ButtonBehaviour script in the inspector.
I created below C# script.
public GameObject sph;
public void Example()
{
score++;
aaz = Position();
Textfeild2.text = score.ToString() + "New Pos =" + aaz;
sph.SetActive(false);
}
I attached the script to Game Object and dropped Sphere on sph and Updated the Onclick() of MRTK button. Am I missing anything else?
Attaching Image