I’m trying to switch between two canvases, I used the thread, How do I reference a canvas? , to come up with this code:
public Canvas p1;
public Canvas p2;
void start(){
GameObject tempObject1 = GameObject.Find("Programs1");
GameObject tempObject2 = GameObject.Find("Programs2");
p1 = tempObject1.GetComponent<Canvas> ();
p2 = tempObject2.GetComponent<Canvas> ();
}
public void forward1(){
p1.enabled = false;
p2.enabled = true;
}
There are no errors directly in the code, but when I press the button assigned with this script I get this error:
UnassignedReferenceException: The variable p1 of programCanvases has not been assigned.
You probably need to assign the p1 variable of the programCanvases script in the inspector.
This same error also applies to the variable p2.