!IsActive && !GetRunInEditMode

I’m setting active with SetActive on a gameobject and I’m getting this error when I run the game and it hits that line of code. It appears to be running fine, but would like to understand and clear this out. Anybody ever get this error? I don’t want to post code because it would be a lot of code and I can just work around it.

I got the same obscure error message that appears to be a lost debugging trap for an odd condition.

By way of example, my case was narrowed down to a gameObject.SetActive(false) call from within the OnGUI method, as opposed to Update() or FixedUpdate().

Presumably, the tick cycle chain should be respected for cases where a game object can deactivate itself, and these operations should be performed outside OnGUI(). Hope that helps.

Yes I had the same problem/error. And it all happens if I try to disable gameobject in OnGUI as described. OnGUI happens more than one tick and for different events. If the correct event does not occur you function won’t work. For example if you are pressing a button to deactivate gameobject you would find two events: “Layout and mouseDown”. You can simply filter events with IF statement

if (Event.current.type == EventType.mouseDown)
 gameobject.SetActive(false)

I fixed that problem by removing the following DLL: “Assets/Plugins/UnityEditor.dll”;
Note that after removing Unity will probably update it’s interface to original (all your internal windows settings will be discarded)

This is because you are trying to disable an object that it’s in the middle of something, at least that was happend to me, my solution was call the method or copy the code to another method wich the same number of calls from MonoBehaviour, for example:
my code was like this:

`
void OnGUI()
{
    deactivateChilds();
}
    
    void deactivateChilds()
    {
         for( int i = 0; i < transform.childCount; i++ )
         {
    	     transform.GetChild(i).gameObject.SetActive(false);
         }
    }
`

and the solution was to call deactivateChilds() from the Update method.

In my case I had a “HideGui()” function being called from “OnGui()” whenever the H key was pressed, which toggles the active state of the canvas between “Canvas.SetActive(true)” and “Canvas.SetActive(false)”.
My solution was to convert the “HideGui()” function to a coroutine and add the line “yield return new WaitForEndofFrame()” at the beginning. This ensures that whatever other activities in other scripts that were being performed on the canvas have the opportunity to resolve for that frame before the canvas is deactivated. This resolved all of my errors.