- Home /
OnEnable Not Called in UI Canvas?
Hi, I enable or disable my canvas by
myCanvas.enabled=true; //or false
I want to play / stop a movietexture in the canvas.. So I added the movieTexture.play() and stop() in the OnEnable() and OnDisable() in a script attached to the canvas. But the script is never called. I even tried moving the script file to the children of the canvas (RawImage).
Any Pointers?
Thanks & Regards Rajesh
I worked around it by explicitly calling play and pause functions along with canvas.enable/disable.. But still, would like to know if there is something i am missing..
You are disabling the canvas component, not the gameObject! so OnEnable and OnDisable will not be called in his children, only in the Canvas Script it self;
Answer by hulahoolgames · Jan 17, 2016 at 02:27 AM
Instead try myCanvas.gameObject.SetActive(true/false) This should call the OnEnable and OnDisable functions.
Your answer
