I am confused about enabling/disabling activating/deactivating game objects, and their relationship to the OnEnable() callback. For example there are three variations:
a) myGameObject.enabled = true;
b) myGameObject.active = true; (I’ve read that this is depreciated and SetActive(true) should be used instead.)
c) myGameObject.SetActive(true);
My questions are:
- What’s the difference between the above? and…
- Does calling “myGameObject.SetActive(true);” cause the OnEnable() callback in the script attached to myGameObject to be called?
Does gameObject have an “enabled” field? From my understanding enabled refers to the state of an individual component where as active refers to a gameObject being active in the scene itself.
The OnEnabled callback should fire anytime the component receives this.enabled = true. I believe that when a gameObject is set to active (which should be done via setActive) all components marked enabled on that object will fire OnEnabled.
If gameObject does possess an enabled field I imagine it would globally enable/disable all components “on” that object.