- Home /
Disabling Canvas Prefab only turns off prefab, not in scene canvas
I have a UI button that when clicked runs the following code
public void UIHide()
{
if (UiCanv.enabled)
{
Debug.Log("UI Hidden");
UiCanv.enabled = false;
}
else
{
Debug.Log("UI Unhidden");
UiCanv.enabled = true;
}
}
The Debug logs come back showing that my code is being reached in both conditions of the if statement, but the canvas in my scene's hierarchy doesn't disable. Rather the prefab I have created does instead. This would be okay if the instance in my scene would update as well, but it does not.
Answer by TheFuzzyketchup · Oct 29, 2017 at 11:03 PM
I found the problem, I was using the prefab in my script for the canvas. I needed to specifically choose the canvas from the hierarchy.
Your answer
Follow this Question
Related Questions
Using raycast to enable canvas that is linked to a prefabs gameobject 0 Answers
Cannot Set Sorting Layer Name in Nested Canvas Prefab 0 Answers
Background color and structure disappear when enabling GUI Canvas 0 Answers
Activate one canvas and deactivating the other. 1 Answer
GameObject is missing a prefab, assign prefab to gameobject 1 Answer