Hello
I am trying to call a GameObject’s OnEnable()
method but I am getting the compile error:
Type
UnityEngine.GameObject' does not contain a definition for
OnEnable’ and no extension methodOnEnable' of type
UnityEngine.GameObject’ could be found (are you missing a using directive or an assembly reference?)
I thought all GameObject’s had the methods OnEnable()
and OnDisable()
? Am I wrong? Is the method private?
public bool managerEnabled {
get {
return managerEnabled;
}
set {
managerEnabled = value;
if(value)
this.gameObject.OnEnable(); // compile error here
else this.gameObject.OnDisable();
}
}