- Home /
Activate desactivate canvas with c#
I turn on and off the canvas but I just:
public bool menu = true public bool otherscene = false;
public void SceneMenu () { menu = true otherscene = false;
}
but it will not know how to say it or attach the canvas
Answer by Gatau · Jul 25, 2015 at 07:02 PM
If you want to activate a disabled object you can place it in a variable and use the SetActive() function by using something like this:
public GameObject canvasObject; // drag your canvas object to this variable in the editor
// make your canvas active from a disables state by calling this method
public void MakeActive()
{
canvasObject.SetActive(true);
}
If this is not what you need then please explain more because it was hard to understand what you wanted to achieve.
This answer doesn't work - Dragging and dropping a canvas into the public input doesn't work and it is restricted to Game Objects.
Of course it works you actually drag n drop the GameObject that "contains" the Canvas Component so IT IS a GameObject...