- Home /
Override SetActive on a GameObject?
I am trying to debug and find where a gameObject is set to inactive potentially within a group of objects where the SetActive for the specific is not obvious. Is it possible to override SetActive or use some other method to determine which code calls the command?
Answer by Bunny83 · Feb 12, 2018 at 04:02 PM
Just add a Debug.Log inside an OnDisable method of any MonoBehaviour that is attached to the object. The stacktrace of the log entry will contain the origin of the SetActive call.
Just to be clear about your direct question: No, you can't override SetActive since SetActive is not a virtual method and the GameObject class is actually sealed so you can not derive your class from GameObject.
Excellent. With bonus feature that shows if the gameObject itself is activated/inactivated or its parent. Thanks!
@Bunny83 I'm not able to see a stacktrace of the log in Visual Studio for $$anonymous$$ac. There's only one line in it, and that's the OnEnable. Is there a setting I'm missing?