UnityEngine.GameObject:FindGameObjectsWithTag(String) error

When I call

tiles =  GameObject.FindGameObjectsWithTag("Tile")

in a start function
I get this error message in log.

----UnityEngine.GameObject:FindGameObjectsWithTag(String)
----State:Start() (at Assets/Loopy/scripts/Objects/State.boo:19)
!go.IsActive() || !go.GetTag() != 0
UnityEngine.GameObject:FindGameObjectsWithTag(String)

everything seems work ok all the tagged objects are found and returned, but error messages worry me. Is this a real error?

Cheers
Grant

What version of Unity are you using?

1.6.2f1
build 7844

I get this error a lot also:

It doesn’t seem to affect anything though.

Well, five years later, and there doesn’t seem to have been any resolution on this. It’s happening to me, in version 3.5, but, as others have noted, doesn’t seem to have any negative impact.

Still, I’d like to understand why it’s happening and clean it up.

Oh, and it only seems to occur when you drop out of Play mode back in to Edit mode.

1 Like

It’s still happening in 4.1.3f3…

It’s not happening to me.

@agentsmith: what’s your code look like?

It’s infrequent and I can’t reproduce it but every now and then it pops up … I think it’s because it’s in OnEnable(); I’ve ran into issues with it before but I’m guessing it has to do with OnEnable()'s execution order. I have a singleton class that has “DontDestroyOnLoad” and OnEnable and OnDisable always get called twice. It’s strange because I’ll put a bool in there so it will only run once but it still runs it twice. Each time setting the bool to false and completely “ignoring” the check. Whatever I’m passed it…

 void OnEnable ( )
{
        if (myPlayer == null)
        {
             GameObject[] players;
             players = GameObject.FindGameObjectsWithTag ( "Player" ); // <--- receives error

            // code stuff

}

You’re probly right. I don’t know what else to tell you other than reporting a bug to UT…

Aww crap it wasn’t OnEnable it was OnLevelWasLoaded that it was calling it twice on my DontDestroyOnLoad gameobject… But the OP’'s error was from OnEnable and the code snippet from my previous post. The execution order is a little more complex depending on the situation:

Still I am getting this error. Anybody has some solution for it?

Unity 5.3.2f1 and I occasionally get this too. Amazing that it was first discovered in Unity 1.6.2

if you use GameObject.FindGameObjectWithTag in OnEnable this error appears

I am having the same problem…please help …
go.IsActive() && go.GetTag() != 0
UnityEngine.Camera:get_main()…

ignore it , this error does not cause any problem

Lovely error)) Get it when call Camera.main, but there is not camera main in scene. And it is ok for me. How I can turn this error off?

my Unity 5.1.2

Unity 5.4, still the problem persists.

I had a similar problem and the solution is to check if camera is active or not:

        if (Camera.current == null)
        {
            Debug.Log("CAMERA IS INACTIVE");
            return;
        }
2 Likes

It says it shows that error if the searched gameobject has already been destroyed