Hey. I’m having trouble with Unity. I don’t know whats going on. I don’t know what caused this. It has continued to creep up on me as In work. I have not touched my objectpooler or my gun scripts. The editor seems to be losing references or something. SetActive() is not working recursively as it should. Some child objects get set others do not. I have video.
I have not upgraded Unity for a while now either.
Video:
Could somebody please tell me what is going on? As I said I have not touched the code that would be affecting these things. If you want the code, I can give you a link to my Github. I don’t have a set up document but I could create one (it may take time).
The setActive(false) does not set the child items inactive, just the item you’re calling it on.
It seems like the in the prefab the child object is not active (as someone mentioned above)
Drag the prefab in the scene to verify everything is enabled to begin with.
Ok nevermind. I just reverted my project. That’s what source control is for. I still don’t know what the problem was.
And if setActive doesn’t work on the child objects why is SetActiveRecursively obsolete like I said? It works on other objects tbph. I can call setactive on a parent object and its children all get their state set.
What I mean is that, in the inspector, the child gameobjects’ active checkbox remains untouched when using SetActive on the parent item. Inspecting the UnityEngine dll:
[Obsolete(“gameObject.SetActiveRecursively() is obsolete. Use GameObject.SetActive(), which is now inherited by children.”)]
I imagine there was a time, a long time ago, where the child gameobjects didn’t inherit some “active” property from the parent, so you needed to use SetActiveRecuseively. It must have been pre-Unity 5.0, because it isn’t even in the scripting reference from version 5.0.
I originally had a problem with SetActive(). The problem was that it didn’t seem to be changing the active state of the child objects. I tried setactiverecursively() but soon learned that was obsolete.
Looking back at the video… I do believe TTTTTa was correct. I knew the child prefab object wasn’t active but I didn’t know why. Now the reason might be that my GenericBulle.cs script was attached to the prefab and not the parent. Which makes total sense.
When I get confused I get frustrated and its a hard trap to get out of.