Search Unity

Error when applying my prefab

Discussion in 'Editor & General Support' started by Samuel411, May 24, 2018.

  1. Samuel411

    Samuel411

    Joined:
    Dec 20, 2012
    Posts:
    646
    I'm having trouble applying my prefab. Other prefabs apply normally but when I apply one in specific, my scene manager, I get this error, and it doesn't apply. I've attempted to reimport my assets, restart Unity and everything. I'm using Unity 2018.1.0f2:

    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. UnityEditor.PrefabUtility.RegisterNewObjects (System.Collections.Generic.List`1 newHierarchy, System.Collections.Generic.List`1 hierarchy, System.String actionName) (at C:/buildslave/unity/build/Editor/Mono/ImportSettings/PrefabUtility.cs:113)
    3. UnityEditor.PrefabUtility.ReplacePrefabWithUndo (UnityEngine.GameObject target) (at C:/buildslave/unity/build/Editor/Mono/ImportSettings/PrefabUtility.cs:217)
    4. UnityEditor.GameObjectInspector.DoPrefabButtons (PrefabType prefabType, UnityEngine.GameObject go) (at C:/buildslave/unity/build/Editor/Mono/Inspector/GameObjectInspector.cs:348)
    5. UnityEditor.GameObjectInspector.DrawInspector () (at C:/buildslave/unity/build/Editor/Mono/Inspector/GameObjectInspector.cs:261)
    6. UnityEditor.GameObjectInspector.OnHeaderGUI () (at C:/buildslave/unity/build/Editor/Mono/Inspector/GameObjectInspector.cs:171)
    7. UnityEditor.Editor.DrawHeader () (at C:/buildslave/unity/build/Editor/Mono/Inspector/Editor.cs:428)
    8. UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor[] editors, Int32 editorIndex, Boolean rebuildOptimizedGUIBlock, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect) (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1167)
    9. UnityEditor.InspectorWindow.DrawEditors (UnityEditor.Editor[] editors) (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1072)
    10. UnityEditor.InspectorWindow.OnGUI () (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:412)
    11. System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
    12. Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
    13. System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)
    14. System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
    15. UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:291)
    16. UnityEditor.HostView.Invoke (System.String methodName) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:284)
    17. UnityEditor.HostView.InvokeOnGUI (Rect onGUIPosition) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:251)
    18.  
     
  2. joeyether40

    joeyether40

    Joined:
    Jan 26, 2018
    Posts:
    20
    I am getting the exact same error . Did you find a resolution to the problem
     
  3. Samuel411

    Samuel411

    Joined:
    Dec 20, 2012
    Posts:
    646
    Yeah, I updated Unity to the latest version, seemed to fix everything. When I stayed with the same version of unity the issue went away for a day and came back and this repeated like 5 times so I just upgraded completely.
     
  4. AtifatGamy

    AtifatGamy

    Joined:
    Jul 5, 2018
    Posts:
    1
    This problem is due to a "Missing Reference Script" in your prefab. Somewhere in its hierarchy, you have a Missing Script or a Missing Prefab (in your drag&drops elements, probably).

    I've deleted the components with "Missing Reference Script" and set to "None" drag&drop elements in my inspector, reapply, and it worked !
     
    hashim likes this.