Search Unity

Error: ShouldRunBehaviour () - What is this? I can't find any reference to this error online.

Discussion in 'Scripting' started by Void24, Apr 13, 2015.

  1. Void24

    Void24

    Joined:
    Oct 15, 2013
    Posts:
    50
    I get it when using SendMessage. I have never seen it before and searches to the unity forums as well as google return zero results of any kind that reference this message.

    Error: ShouldRunBehaviour ()

    Anyone know what this means?
     
  2. Deleted User

    Deleted User

    Guest

    Is this a method in your class by chance?
     
  3. ggombau

    ggombau

    Joined:
    Apr 7, 2015
    Posts:
    3
    Hello

    I've found the same problem.

    I have one gameObject with two scripts in the first one I have this call:

    SendMessage("updateData",null,SendMessageOptions.DontRequireReceiver);

    And in the second one I've an updateData method. It works but it shows this error on the console.

    ShouldRunBehaviour ()
    UnityEngine.GameObject:SendMessage(String, Object, SendMessageOptions)
    ScriptAonChanged() (at assets/Scripts/ScriptA.cs:56)
    ScriptAInspector:OnSceneGUI() (at assets/Editor/ScriptAInspector.cs:64)
    UnityEditor.DockArea:OnGUI()


    Did you find any solution?

    Thanks
     
  4. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    It's probably much like IEnumerator.MoveNext is with coroutines - it's what Unity uses behind the scenes to carry out the SendMessage functionality. If you look 1 line below it in the stacktrace, it'll point you to where the actual error is (in the most recent post, line 56 of ScriptA.cs).
     
  5. ggombau

    ggombau

    Joined:
    Apr 7, 2015
    Posts:
    3
    Thank you StarManta,

    It seems that the problem is that sendMessage has to be used on run and it works on edit but showing this error message.

    I'm looking for any other solution to do this during edit.
     
    oferei likes this.
  6. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,338
    Whenever you get an error message like "ShouldRunBehaviour()" or "o != i" or "IsFinite(result)", that's a failed assertion. Assertions are like exceptions, but they don't show the line number of the error, or any usefull information at all.

    So what you're seeing is probably the result of a line looking like this:

    Code (CSharp):
    1. Debug.Assert(ShouldRunBehaviour());
    Where Debug is System.Diagnostics.Debug, not UnityEngie.Debug.
     
    Bothorth likes this.
  7. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    If you are using Unity 4.6 or above you could make this go away by refactoring out the SendMessage call and replacing it with ExecuteEvents. This may or may not be worth the hassle.
     
  8. ggombau

    ggombau

    Joined:
    Apr 7, 2015
    Posts:
    3
    Thank you Baste and BoredMormon,

    Finally the ExecuteEvents solution is what I've found it solves the problem.
     
  9. oferei

    oferei

    Joined:
    Dec 1, 2012
    Posts:
    36
    ExecuteEvents works well (and quietly) in edit mode, but it doesn't offer an easy way to recurse down the hierarchy. You'll have to iterate over all the children yourself.
     
    Last edited: Oct 5, 2015
  10. RChrispy

    RChrispy

    Joined:
    Dec 18, 2013
    Posts:
    71
    Hey,
    I was running in the same issue and used System.Reflection and .Invoke to solve this error message. It is a relatvely good alternative in my opinion.

    Code (CSharp):
    1. MethodInfo tMethod = TargetObjects[i].GetType().GetMethod(tAttribute.FunctionName);
    2.                          if(tMethod != null)
    3.                          {
    4.                              tMethod.Invoke(TargetObjects[i], null);
    5.                              break;
    6.                          }
    Full Code: http://answers.unity3d.com/questions/1088471/customattribute-on-class-or-method.html
     
    Nick-Nexefy likes this.
  11. parkman

    parkman

    Joined:
    Oct 27, 2015
    Posts:
    1
    Because the method cannot run in editMode,you should add "[ExecuteInEditMode]"
     
    wlad_s, Neatou and liyokikon like this.
  12. fpilote

    fpilote

    Joined:
    Jul 19, 2013
    Posts:
    5
    if you want to call the "Update" method through a SendMessage from the "edit mode", make sure the MonoBehavior you are sending the message to has the "runInEditMode" property set to true.
     
    BennyKokMusic likes this.
  13. smetzzz

    smetzzz

    Joined:
    Mar 24, 2014
    Posts:
    145
    [ExecuteInEditMode] worked for me. Thanks!
     
  14. wannesboeykens

    wannesboeykens

    Joined:
    Aug 3, 2020
    Posts:
    1
    Can someone help me? I get this error message:
    Assertion failed on expression: 'ShouldRunBehaviour()'
    UnityEngine.Canvas:SendWillRenderCanvases()