Search Issue Tracker

By Design

Votes

2

Found in

2018.3.0a1

2018.3.2f1

2019.1.0a1

2019.2.0a1

Issue ID

1123857

Regression

No

Assertion failed on expression: 'ShouldRunBehaviour()' error is thrown when prefab with custom script is edited

Scripting

-

To reproduce:
1. Open user's attached project ("Prefab Editing Test")
2. Select "Test Prefab" in Hierarchy window and enter prefab mode
3. Inspect the console

Expected: No error is thrown
Actual: Error is thrown

Reproduced with: 2018.3.5f1, 2019.1.0b2, 2019.2.0a4

  1. Resolution Note:

    This is by design:
    Baker is marked with [ExecuteInEditMode] so within the editor, in edit mode it calls SendMessage("Bake") with default options (which is RequiresReceiver). As PrefabEditingTest (the behaviour with the method Bake) is not marked with [ExecuteInEditMode]/[ExecuteAlways], it does not receive the message and the assertion fails.

Comments (3)

  1. unity_7slov5

    Nov 21, 2022 12:58

    good day everyone I got such an error when one of the sprites that I added to the scene in parallel was rejected in the graphic editing program. I hope it helps someone

  2. FabDynamic

    Oct 17, 2019 20:14

    I have this problem as well. Applying [ExecuteInEditMode] liberally on receiving classes does seem to make it go away. The following forum thread from 2015 describes the same problem and workaround which suggests that the problem has been around since 2015.

    https://forum.unity.com/threads/error-shouldrunbehaviour-what-is-this-i-cant-find-any-reference-to-this-error-online.318517/

  3. btristan

    Mar 14, 2019 14:47

    This error also occurs when GameObject.BroadcastMessage executes a method on a class NOT marked as ExecuteInEditor while in edit mode. The method also gets executed, which should probably not happen unless the class is marked with ExecuteInEditor.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.