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

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?

1 Like

Is this a method in your class by chance?

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

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).

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.

1 Like

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:

Debug.Assert(ShouldRunBehaviour());

Where Debug is System.Diagnostics.Debug, not UnityEngie.Debug.

1 Like

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.

Thank you Baste and BoredMormon,

Finally the ExecuteEvents solution is what Iā€™ve found it solves the problem.

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.

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.

MethodInfo tMethod = TargetObjects[i].GetType().GetMethod(tAttribute.FunctionName);
                         if(tMethod != null)
                         {
                             tMethod.Invoke(TargetObjects[i], null);
                             break;
                         }

Full Code: CustomAttribute on Class or Method ( EDIT: Button to call methods) - Questions & Answers - Unity Discussions

1 Like

Because the method cannot run in editMode,you should add ā€œ[ExecuteInEditMode]ā€

3 Likes

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.

1 Like

[ExecuteInEditMode] worked for me. Thanks!

Can someone help me? I get this error message:
Assertion failed on expression: ā€˜ShouldRunBehaviour()ā€™
UnityEngine.Canvas:SendWillRenderCanvases()