- Home /
Question by
jellygamingplayz · Jan 07, 2019 at 08:32 PM ·
c#gameobjectcanvas
[C#] Disabling canvas with one script and then accessing it in another to say when it is disabled do this but the first script isn't disabling.
Hi, I have made a script that enables a canvas if a certain gameobject isnt active in the hierarchy
here is the first script
public void Update()
{
if (trigger.activeInHierarchy == false)
{
canvasToShow.enabled = true;
}
else if(trigger.activeInHierarchy == true)
{
canvasToShow.enabled = false;
}
}
the second script is a script that disables player movement when the canvas is enabled.
public void Start() { if(canvas.enabled == true) { controller.enabled = false; Cursor.lockState = CursorLockMode.None; Cursor.visible = true; }
else if(canvas.enabled == false)
{
controller.enabled = true;
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
}
my problem is that when i start the game i cant move because for some reason the first script isnt disabling the canvas.
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612185318im_/https://answers.unity.com/themes/thub/images/avi.jpg)