Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

(Case 1108041) AddComponent to Prefab in AssetPostprocessor causes assertion

Discussion in 'Prefabs' started by Peter77, Dec 9, 2018.

  1. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,356
    Adding a Component to a Prefab in an AssetPostprocessor, causes the editor to trigger an assertion. This used to work in Unity prior 2018.3.

    Reproduce
    1) Open attached user project
    2) Click "GameObject > 3D Object > Cube"
    3) Drag&drop "Cube" from Hierarchy to Project to create a prefab of it

    Actual
    The editor outputs Assertion failed on expression: '!go.TestHideFlag(Object::kNotEditable)'

    Expected
    No error.


    Code (CSharp):
    1. Assertion failed on expression: '!go.TestHideFlag(Object::kNotEditable)'
    2.  
    3. UnityEngine.GameObject:Internal_AddComponentWithType()
    4. UnityEngine.GameObject:AddComponent(Type) (at C:\buildslave\unity\build\Runtime\Export\GameObject.bindings.cs:221)
    5. UnityEngine.GameObject:AddComponent() (at C:\buildslave\unity\build\Runtime\Export\GameObject.bindings.cs:226)
    6. PrefabReferenceProcessor:OnPostprocessInternal(String) (at Assets\Editor\PrefabReferenceProcessor.cs:48)
    7. PrefabReferenceProcessor:OnPostprocessAllAssets(String[], String[], String[], String[]) (at Assets\Editor\PrefabReferenceProcessor.cs:33)
    8. System.Reflection.MonoMethod:InternalInvoke()
    9. System.Reflection.MonoMethod:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)
    10. System.Reflection.MethodBase:Invoke(Object, Object[])
    11. UnityEditor.AssetPostprocessingInternal:PostprocessAllAssets(String[], String[], String[], String[], String[]) (at C:\buildslave\unity\build\Editor\Mono\AssetPostprocessor.cs:141)
    12. UnityEditorInternal.InternalEditorUtility:ProjectWindowDrag()
    13. UnityEditor.LocalGroup:DoDrag(Int32, Boolean) (at C:\buildslave\unity\build\Editor\Mono\ObjectListLocalGroup.cs:1247)
    14. UnityEditor.LocalGroup:HandleUnusedDragEvents(Single) (at C:\buildslave\unity\build\Editor\Mono\ObjectListLocalGroup.cs:270)
    15. UnityEditor.Group:Draw(Single, Vector2, Int32&) (at C:\buildslave\unity\build\Editor\Mono\ObjectListGroup.cs:161)
    16. UnityEditor.ObjectListArea:HandleListArea() (at C:\buildslave\unity\build\Editor\Mono\ObjectListArea.cs:1330)
    17. UnityEditor.ObjectListArea:OnGUI(Rect, Int32) (at C:\buildslave\unity\build\Editor\Mono\ObjectListArea.cs:541)
    18. UnityEditor.ProjectBrowser:OnGUI() (at C:\buildslave\unity\build\Editor\Mono\ProjectBrowser.cs:1965)
    19. System.Reflection.MonoMethod:InternalInvoke()
    20. System.Reflection.MonoMethod:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)
    21. System.Reflection.MethodBase:Invoke(Object, Object[])
    22. UnityEditor.HostView:Invoke(String, Object) (at C:\buildslave\unity\build\Editor\Mono\HostView.cs:342)
    23. UnityEditor.HostView:Invoke(String) (at C:\buildslave\unity\build\Editor\Mono\HostView.cs:336)
    24. UnityEditor.HostView:InvokeOnGUI(Rect, Rect) (at C:\buildslave\unity\build\Editor\Mono\HostView.cs:302)
    25. UnityEditor.DockArea:DrawView(Rect, Rect, Boolean, Boolean, Boolean) (at C:\buildslave\unity\build\Editor\Mono\GUI\DockArea.cs:363)
    26. UnityEditor.DockArea:OldOnGUI() (at C:\buildslave\unity\build\Editor\Mono\GUI\DockArea.cs:322)
    27. UnityEngine.Experimental.UIElements.IMGUIContainer:DoOnGUI(Event, Matrix4x4, Rect, Boolean) (at C:\buildslave\unity\build\Modules\UIElements\IMGUIContainer.cs:244)
    28. UnityEngine.Experimental.UIElements.IMGUIContainer:HandleIMGUIEvent(Event, Matrix4x4, Rect) (at C:\buildslave\unity\build\Modules\UIElements\IMGUIContainer.cs:438)
    29. UnityEngine.Experimental.UIElements.IMGUIContainer:HandleIMGUIEvent(Event) (at C:\buildslave\unity\build\Modules\UIElements\IMGUIContainer.cs:421)
    30. UnityEngine.Experimental.UIElements.IMGUIContainer:HandleEvent(EventBase) (at C:\buildslave\unity\build\Modules\UIElements\IMGUIContainer.cs:401)
    31. UnityEngine.Experimental.UIElements.EventDispatcher:PropagateEvent(EventBase) (at C:\buildslave\unity\build\Modules\UIElements\EventDispatcher.cs:754)
    32. UnityEngine.Experimental.UIElements.EventDispatcher:ProcessEvent(EventBase, IPanel) (at C:\buildslave\unity\build\Modules\UIElements\EventDispatcher.cs:599)
    33. UnityEngine.Experimental.UIElements.EventDispatcher:Dispatch(EventBase, IPanel, DispatchMode) (at C:\buildslave\unity\build\Modules\UIElements\EventDispatcher.cs:307)
    34. UnityEngine.Experimental.UIElements.BaseVisualElementPanel:SendEvent(EventBase, DispatchMode) (at C:\buildslave\unity\build\Modules\UIElements\Panel.cs:176)
    35. UnityEngine.Experimental.UIElements.UIElementsUtility:DoDispatch(BaseVisualElementPanel) (at C:\buildslave\unity\build\Modules\UIElements\UIElementsUtility.cs:245)
    36. UnityEngine.Experimental.UIElements.UIElementsUtility:ProcessEvent(Int32, IntPtr) (at C:\buildslave\unity\build\Modules\UIElements\UIElementsUtility.cs:68)
    37. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr) (at C:\buildslave\unity\build\Modules\IMGUI\GUIUtility.cs:179)
     
    LeonhardP likes this.
  2. quitebuttery

    quitebuttery

    Joined:
    Mar 12, 2011
    Posts:
    313
    I get this same error--in this case playmaker is causing it somehow.

    Code (CSharp):
    1. Assertion failed on expression: '!go.TestHideFlag(Object::kNotEditable)'
    2. UnityEngine.GameObject:AddComponent()
    3. PlayMakerFSM:GetEventHandlerComponent(GameObject) (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/PlayMakerFSM.cs:469)
    4. PlayMakerFSM:AddEventHandlerComponent() (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/PlayMakerFSM.cs:447)
    5. PlayMakerFSM:AddEventHandlerComponents() (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/PlayMakerFSM.cs:385)
    6. PlayMakerFSM:Preprocess() (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/PlayMakerFSM.cs:225)
    7. HutongGames.PlayMakerEditor.PlayMakerBuildCallbacks:OnPostprocessScene() (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/Editor/PlayMakerBuildCallbacks.cs:34)
    8. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
     
  3. zeroChi

    zeroChi

    Joined:
    Sep 19, 2017
    Posts:
    3
    2018.3.5f1
    same question