Search Unity

UnityEngine.GameObject:FindGameObjectsWithTag(String) error

Discussion in 'Scripting' started by Ryuuguu, Apr 28, 2007.

  1. Ryuuguu

    Ryuuguu

    Joined:
    Apr 14, 2007
    Posts:
    335
    When I call
    Code (csharp):
    1. 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
     
  2. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    4,879
    What version of Unity are you using?
     
  3. Ryuuguu

    Ryuuguu

    Joined:
    Apr 14, 2007
    Posts:
    335
    1.6.2f1
    build 7844
     
  4. bronxbomber92

    bronxbomber92

    Joined:
    Nov 11, 2006
    Posts:
    890
    I get this error a lot also:

    It doesn't seem to affect anything though.
     
  5. memetic-arts

    memetic-arts

    Joined:
    Feb 27, 2011
    Posts:
    82
    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.
     
  6. memetic-arts

    memetic-arts

    Joined:
    Feb 27, 2011
    Posts:
    82
    Oh, and it only seems to occur when you drop out of Play mode back in to Edit mode.
     
    abbas352 likes this.
  7. agentsmith

    agentsmith

    Joined:
    May 1, 2010
    Posts:
    132
    It's still happening in 4.1.3f3...
     
  8. HonorableDaniel

    HonorableDaniel

    Joined:
    Feb 28, 2007
    Posts:
    2,915
    It's not happening to me.

    @agentsmith: what's your code look like?
     
  9. agentsmith

    agentsmith

    Joined:
    May 1, 2010
    Posts:
    132
    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...


    Code (csharp):
    1.  
    2.  void OnEnable ( )
    3. {
    4.         if (myPlayer == null)
    5.         {
    6.              GameObject[] players;
    7.              players = GameObject.FindGameObjectsWithTag ( "Player" ); // <--- receives error
    8.  
    9.             // code stuff
    10.  
    11. }
    12.  
     
  10. HonorableDaniel

    HonorableDaniel

    Joined:
    Feb 28, 2007
    Posts:
    2,915
    You're probly right. I don't know what else to tell you other than reporting a bug to UT...
     
  11. agentsmith

    agentsmith

    Joined:
    May 1, 2010
    Posts:
    132
  12. siddharth3322

    siddharth3322

    Joined:
    Nov 29, 2013
    Posts:
    767
    Still I am getting this error. Anybody has some solution for it?
     
  13. ShuuGames

    ShuuGames

    Joined:
    Jun 25, 2013
    Posts:
    188
    Unity 5.3.2f1 and I occasionally get this too. Amazing that it was first discovered in Unity 1.6.2
     
  14. DGart.work

    DGart.work

    Joined:
    Mar 27, 2015
    Posts:
    199
    if you use GameObject.FindGameObjectWithTag in OnEnable this error appears
     
  15. abbas352

    abbas352

    Joined:
    Aug 21, 2015
    Posts:
    1
    I am having the same problem...please help ...
    go.IsActive() && go.GetTag() != 0
    UnityEngine.Camera:get_main()...
     
  16. DGart.work

    DGart.work

    Joined:
    Mar 27, 2015
    Posts:
    199
    ignore it , this error does not cause any problem
     
  17. mmortall

    mmortall

    Joined:
    Dec 28, 2010
    Posts:
    81
    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
     
  18. AgentFire

    AgentFire

    Joined:
    Jul 19, 2014
    Posts:
    4
    Unity 5.4, still the problem persists.
     
  19. mizdler

    mizdler

    Joined:
    Dec 9, 2016
    Posts:
    1
    I had a similar problem and the solution is to check if camera is active or not:
    Code (CSharp):
    1.         if (Camera.current == null)
    2.         {
    3.             Debug.Log("CAMERA IS INACTIVE");
    4.             return;
    5.         }
     
    siddharth3322 and ngunggu like this.
  20. HJ8141

    HJ8141

    Joined:
    Mar 10, 2017
    Posts:
    1
  21. ngunggu

    ngunggu

    Joined:
    May 16, 2017
    Posts:
    1
    Thank you mizdler:)
     
unityunity