Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Unity Error: !IsPlayingOrEditMode ?

Discussion in 'Editor & General Support' started by JR, Mar 4, 2008.

  1. JR

    JR

    Joined:
    Mar 27, 2007
    Posts:
    29
    Hi,

    what might be the reason Unity 2.0.2 gives an error to the console: !IsPlayingOrEditMode? The full error is:

    !IsPlayingOrEditMode ()
    UnityEngine.SendMouseEvents:DoSendMouseEvents()

    [/Users/unity-build/Desktop/automatic-build-2/unity/Projects/../Runtime/Mono/MonoBehaviour.cpp line 721]

    After this error something funny may happen: like editing object positions may not work in the sense that the objects may be returned to their positions before this error, however things feel pretty random to me.

    Please note, I'm NOT trying to do editor scripting or something like that in my project.

    Thanks,
    -JR
     
  2. cecarlsen

    cecarlsen

    Joined:
    Jun 30, 2006
    Posts:
    858
    I get the same error. Possibly since v. 2.0.2.

    ~ce
     
  3. CoherentInk

    CoherentInk

    Joined:
    Jul 16, 2006
    Posts:
    216
    Yep. I've been getting the same error pretty consistently now. Again, I'm not doing any editor scripting. Anyone know what might cause this?
     
  4. Doug

    Doug

    Joined:
    Oct 19, 2007
    Posts:
    36
    I've been getting it too. At first I thought it was the scripts in my Editor folder, but I deleted all of them and it still happens.

    Doesn't seem to do anything bad, but I'm sure we all hate seeing that red X!
     
  5. JFo

    JFo

    Joined:
    Dec 9, 2007
    Posts:
    217
    Any news for this subject? Has anyone managed to track the reason for this error?
     
  6. DannyJ

    DannyJ

    Joined:
    Sep 3, 2007
    Posts:
    40
    I am getting the same error message and also experience the problem that newly linked prefabs dragged to variables exposed in the inspector frequently are forgetten and they need to be linked a second time. This is happening in Unity v2.0.2
     
  7. AngryAnt

    AngryAnt

    Keyboard Operator

    Joined:
    Oct 25, 2005
    Posts:
    3,045
    Wow. Plenty of people with this error. How about reproducing the error in a simplified project and sending that via the bug reporter? One from each if possible to determine if the cause is the same.
     
  8. yangmeng

    yangmeng

    Joined:
    Dec 5, 2006
    Posts:
    573
    I am actually getting this error a lot and having positions of objects changed around in the editor without my touching them when this warning comes up...
     
  9. Samantha

    Samantha

    Joined:
    Aug 31, 2005
    Posts:
    609
    If the behavior is consistent, please choose Help->Report a Problem, then give us a description of when/where the message is occurring and attach your project folder. We'll try to reproduce the issue.
     
  10. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I submitted this bug some time ago (#18418), but it was marked as closed. It still happens and is 100% reproducible, though, so I encourage others to submit this too, so hopefully they can get to the bottom of it. :)

    --Eric
     
  11. careyagimon

    careyagimon

    Joined:
    Dec 20, 2007
    Posts:
    209
    One place I have consistently noticed this bug when I have scripts with OnMouseEnter (and its kin) in the open scene. It seems that Unity will sometimes execute the function while the game is not playing. Since this happens in edit mode, it can affect assets and scene information. One workaround is to add
    Code (csharp):
    1. if (!Application.isPlaying)
    2.     return;
    to the top of your OnMouseEnter functions. I haven't tested to see if this is still a problem in 2.1.
     
  12. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Yeah, that's basically what I ended up doing (although the error message still appears). And yep, it's still a problem in 2.1.

    --Eric
     
  13. dock

    dock

    Joined:
    Jan 2, 2008
    Posts:
    603
    Thanks for the tip, this was driving me crazy! :)
     
  14. potan

    potan

    Joined:
    Nov 2, 2008
    Posts:
    177
    sorry to bump an old thread,
    but lately i'm getting a lot of this warning, hopefully
    this doesn't break the game :p

    Is this something serious though ??
     

    Attached Files:

  15. dock

    dock

    Joined:
    Jan 2, 2008
    Posts:
    603
    Nah, I get it all the time too, I regard it as a bug in Unity somewhat. :(
     
  16. Cybexx

    Cybexx

    Joined:
    Dec 4, 2008
    Posts:
    23
    Thank you so much, I just started having this problem today and right at the end of a project too. I changed a few buttons so that they would change color when you moused over them. So I was using OnMouseEnter and OnMouseExit.

    In the editor if I tried to drag a Material on to them it would call those functions and they would permanently change to that color. It also happened when I was switching back to Unity from Unitron.

    Adding your code to those functions fixed my problem though. I hope this problem is addressed in 2.5, I could see it causing huge problems to certain games.
     
  17. headkitgames

    headkitgames

    Joined:
    Oct 30, 2009
    Posts:
    23
    still have it in 2.6
     
  18. rouhee

    rouhee

    Joined:
    Dec 23, 2008
    Posts:
    194
    now i got this and it is really annoying. It floods the console with the error:

    The version is 2.6.1f3

    :(
     
  19. wbokunic

    wbokunic

    Joined:
    Dec 17, 2009
    Posts:
    43
    Bumping. I'm also getting this error and don't know what's causing it =/

    !IsPlayingOrEditMode ()
    UnityEngine.GameObject:SendMessage(String, Object, SendMessageOptions)
    UnityEngine.GameObject:SendMessage(String, Object, SendMessageOptions)
    UnityEngine.MouseOverPair:SendMessage(String)
    UnityEngine.SendMouseEvents:DoSendMouseEvents()

    [..\..\Runtime\Mono\MonoBehaviour.cpp line 806]

    I thought it was related to a Send Message from a mouse over event, but even after disabling everything that did that I still got this issue.
     
  20. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    Is this with an editor script? Are you actually calling SendMessage yourself anywhere?
     
  21. esvaldo

    esvaldo

    Joined:
    Dec 11, 2009
    Posts:
    52
    I'm having this bug also.. And no, I'm not using any editor script

    :?
     
  22. maikkel

    maikkel

    Joined:
    Sep 24, 2010
    Posts:
    20
    Same thing here!

    Code (csharp):
    1. !IsPlayingOrEditMode ()
    2. UnityEngine.GameObject:SendMessage(String, Object, SendMessageOptions)
    3. UnityEngine.GameObject:SendMessage(String, Object, SendMessageOptions)
    4. UnityEngine.MouseOverPair:SendMessage(String)
    5. UnityEngine.SendMouseEvents:DoSendMouseEvents()
    6.  
    7. [..\..\Runtime\Mono\MonoBehaviour.cpp line 806]
     
  23. mooktown

    mooktown

    Joined:
    Feb 12, 2011
    Posts:
    5
    yup, I'm getting this now too, it's actually stopping script changes from taking effect and I cant add a new script to my project because unity refuses to compile the new script until this error is gone it seems.. what could be causing it ffs!?

    EDIT: turned out to be the iTweenPath.cs script I was trying to use from earlier causing this for me :)
     
    Last edited: Feb 12, 2011
  24. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    That's cute. Just updated to Unity 3.4 and am getting exactly this error :). Unfortunately no indication about what is going on exactly. It is caused in MonoBehaviour.cpp line 533.
     
  25. foobag

    foobag

    Joined:
    Jul 8, 2011
    Posts:
    7
    Same here. I never had the problem, but since upgrading to 3.4 (from 3.2), I constantly get this error in the console. WTF!
     
  26. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    In my case it is related to threads. In play mode a few threads are started. When I finish the playmode by clicking play again, this error appears.
     
  27. vandread

    vandread

    Joined:
    Aug 23, 2011
    Posts:
    1
    I just started having the same problem in Unity 3.4
    I *think* i tracked it down to a prefab spawner method that was being called via InvokeRepeating(), which was started within an OnEnable() callback.
    Im guessing somehow the prefabs were being spawned in edit-mode, because by adding couple of Application.isPlaying checks, the problem went away.
     
  28. scritchy

    scritchy

    Joined:
    Dec 30, 2010
    Posts:
    94
    Have same problem as well. don't have the faintest idea what is causing it, or where to even start looking
     
  29. Mårten

    Mårten

    Joined:
    May 16, 2011
    Posts:
    18
    I get this as well, from a GameObject.SendMessage() call that is called by an editor script (not playing). When it is called during play I don't get the error.

    The call works so it's mostly annoying, but I need to have the SendMessage sent so I can't use the Application.isPlaying workaround either :(
     
  30. scritchy

    scritchy

    Joined:
    Dec 30, 2010
    Posts:
    94
    how are you guys even tracing this? my output window simply says:


    !IsPlayingOrEditMode ()

    and in the toolbar below:
    Assert in file: /Applications/......../Monobehaviour.cpp at line: 533

    i can't even tell what in my project is causing it. doesn't trip the debugger or anything.
     
  31. scritchy

    scritchy

    Joined:
    Dec 30, 2010
    Posts:
    94
    more clues. something unknown causes it, then it will start happening a lot. Like if i click on any particle system gameobject, it will spew out continuously. Restarting editor and going straight to that same particle system no longer does it.

    so it's definitely something modal getting set badly somewhere...
     
  32. pneill

    pneill

    Joined:
    Jan 21, 2007
    Posts:
    207
    Count me in the group that sees this issue. Wish I could get it to stop.
     
  33. nsxdavid

    nsxdavid

    Joined:
    Apr 6, 2009
    Posts:
    476
    Bump same problem. In my case, it was after using the Piecemaker plugin (from the asset store). Once the window is active, it just spams endlessly.
     
  34. Kryptos

    Kryptos

    Joined:
    Mar 30, 2011
    Posts:
    29
    Bump. I have a related issue.
    Sometimes, this cause Unity to lag in play mode. Looking at the profiler I can see that every one or two seconds a call to SendMouseEvents.DoSendMouseEvents() is taking 225 ms (more than 93.4% or the total time used) causing the FPS to drop to 4. Although none of my script is calling this method nor sending any mouse events.
     
  35. ChiuanWei

    ChiuanWei

    Joined:
    Jan 29, 2012
    Posts:
    131
    Make this [ExecuteInEditMode] to //[ExecuteInEditMode] at the beginning..