I understand the difference between activeSelf and activeInHierarchy, and most threads revolve around that.
Hoverer I’m trying to remove warnings from a library I’m using, so I do not know what’s going on there. I only know that it’s using .active and that it works, so I’m wondering what .active defaults to, in order to replace it.
Should I replace it with .activeSelf or with .activeInHierarchy?
No guesses please, it must default to something and I’d like to know just that.
I’ve built a test scene, and apparently it defaults to activeInHierarchy
, which makes perfect sense.
Here’s the code:
using UnityEngine;
using System.Collections;
public class ActiveTest : MonoBehaviour {
public ActiveTest[] children;
public bool testOnAwake;
public void Awake () {
if (testOnAwake) {
Debug.Log(this.name+": testing "+children.Length+" child(ren)");
TestChildren();
}
}
public void TestChildren () {
foreach (ActiveTest test in children) {
test.TestSelf();
}
}
public void TestSelf () {
Debug.Log(this.name+": active="+gameObject.active+", activeSelf="+gameObject.activeSelf+", activeInHierarchy="+gameObject.activeInHierarchy);
}
}