Having big trouble with applying SetActive () on a Canvas
Hello there,
my Canvas needs to be set active manually in order to work correctly.
Let me explain this. I programmed my Canvas having it active all the time. I gave it to a college, so he can incorporate it. (YES, we do not use version control (sad face)). He just enables it by script and all the child-elements get spawned (so the script execution works, but they are not visible on the canvas). One has to disable and enable it manually in the editor for it to work. It is also possible to have it active on launch and disabling it manually. After that enabling it by code works just fine.
This is confusing. Pleeease help me ooooout, it would be appreciated soooooo much (kinda happy face).
Just to clarify, if you call SetActive() on the Canvas, it will be shown. You can see the color of the panel etc. Just the things I generate on it will not be shown. You can see them in the hierarchy though. Also click on them, they all are in the right position, just not visible.
Answer by Halloween_Udo · Feb 10, 2016 at 09:59 AM
Okay, I found it.........
I did set the RectTransform of all my Elements with .SetParent()
. This method takes a Transform and also a boolean value. Set it on false, as suggested by the console if you try to set the parent of a RectTransform with .parent
Your answer
![](https://koobas.hobune.stream/wayback/20220612063550im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Having trouble disabling and enabling game objects 0 Answers
.setActive(true) not functioning. 1 Answer
Is there a way to enable/disable a rigidbody? 1 Answer
Make everything above the floor my player is standing invisible when my camera cant see my character 0 Answers
Turn Off A Script During Collision 1 Answer