I have a compound object which consists of lot of GameObjects and i want to hide it with all children. I want to do it within script attached to this object.
By searching this forum i didn’t find a right way to do it. SetActive works well but i can’t access object after it was disabled. So this way is wrong. I can’t write a correct code for renderer, it says: Property or indexer `UnityEngine.GameObject.renderer’ cannot be assigned to (it is read only) or just hide a parent object, not children.
Can somebody post a code snippet to hide objects?
UPD: Probably the issue was in that i used foreach, which didn’t work.
Thanks, i tried something like this (with foreach) but it didn't work. Your code works!
– maabooI don't use foreach much, but this should do it: Renderer[] arrend = go.GetComponentsInChildren(); foreach (Renderer rend in arrend) { rend.enabled = false; }
– robertbu