Hi guys, I am using a simple if statement script that works very well on both iOS/Web but below shows this “warning”!
the if statement simply check to see if a certain game object is visible before it is allowed to run the remaining code…
if (Cleared.gameObject.active || Failed.gameObject.active){
WARNING: ‘UnityEngine.GameObject.active’ is obsolete. GameObject.active is obsolete. Use GameObject.SetActive(), GameObject.activeSelf or GameObject.activeInHierarchy
what would be the correct way to check if gameObjects are active using an if statement!?
SetActive can be ignored, because that’s to set active.
testing active is ‘activeSelf’:
and ‘activeInHierarchy’:
Check what each returns, and decide for yo’self.
If you are just concerned if it’s active locally to itself, activeSelf is your choice. If you want to know if it’s active in the scene, activeInHierarchy is your choice.
Only if you’ve modified it; the standard version that comes with Unity uses .active, which generates a warning about being obsolete but still works for now.
Thank you sooo much! I had been trying to figure out why SetActive = true or false, and activeInHierarchy gives me errors when .active works and still gives me errors.