Hello,
I followed the instructions of the video to have a damage blood splash screen.
The code did not work with Canvas.enabled = false/true, but with GameObject.SetActive(true/false).
Why is that?
Thank you
Hello,
I followed the instructions of the video to have a damage blood splash screen.
The code did not work with Canvas.enabled = false/true, but with GameObject.SetActive(true/false).
Why is that?
Thank you
Hi StrawHat,
Without knowing anything about your project, I’m afraid I can only guess. Maybe the canvas game object was disabled. In that case, it does not matter whether the Canvas component is enabled or disabled. Unity renders images of active components on active game objects only.
See also:
Yes you are correct! Thank you very much. In the past I solved the issue via changing the type to GameObject.
So, if canvas is disabled by default the canvas.enable = true; will not set it to active.
Therefore, I have to enable them by default at start and then disable or re-enable them at runtime.
If the canvas is managed via code at runtime then the enable = true can re-enable it
is the GameObject.SetActive(bool) a more resource heavy method compared to the .enable = bool; ?
Yes, it does get set to active. However, it is not necessarily also active in the Hierarchy. Only if the parent game object is also active, the Canvas component is active in the Hierarchy. We have to distuinguish between components and game objects. The game object is the wrapper for the components, the Inspector if you will. The components are the boxes in the Inspector of a game object. Transform is a component.
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.