Search Unity

AssetImporter is referencing an asset from the previous import. This should not happen.

Discussion in 'Prefabs' started by litefeel, Oct 12, 2018.

  1. litefeel

    litefeel

    Joined:
    Dec 6, 2016
    Posts:
    45
    Hello.
    The new prefab system is so powers. but it is some issue.

    MySo.cs
    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. #if UNITY_EDITOR
    4. using UnityEditor;
    5. #endif
    6.  
    7. public class MySO : ScriptableObject
    8. {
    9.  
    10.     public GameObject prefab;
    11.  
    12.  
    13. #if UNITY_EDITOR
    14.     [MenuItem("Tools/AddSOToPrefab")]
    15.     public static void AddSOToPrefab()
    16.     {
    17.         var prefab = Selection.activeObject as GameObject;
    18.         if(prefab)
    19.         {
    20.             var so = CreateInstance<MySO>();
    21.             so.name = "MySo";
    22.             so.prefab = prefab;
    23.             Debug.Log(prefab, prefab);
    24.             var path = AssetDatabase.GetAssetPath(prefab);
    25.             AssetDatabase.AddObjectToAsset(so, path);
    26.             AssetDatabase.SaveAssets();
    27.         }
    28.     }
    29.  
    30. #endif
    31. }
    32.  
    1. Create an Prefab and name is MyPrefab
    2. Create MySo and add to MyPrefab
    3. Select MySo and Drag MyPrefab to prefab property.
    4. save it. So far, so good,

    flowing yaml in MyPrefab.prefab

    Code (CSharp):
    1.  
    2. --- !u!114 &114721633881386746
    3. MonoBehaviour:
    4.   m_ObjectHideFlags: 0
    5.   m_CorrespondingSourceObject: {fileID: 0}
    6.   m_PrefabInstance: {fileID: 0}
    7.   m_PrefabAsset: {fileID: 0}
    8.   m_GameObject: {fileID: 0}
    9.   m_Enabled: 1
    10.   m_EditorHideFlags: 0
    11.   m_Script: {fileID: 11500000, guid: 40b994cea1c45b64683d08d6cb75bb44, type: 3}
    12.   m_Name: MySo
    13.   m_EditorClassIdentifier:
    14.   prefab: {fileID: 5928805271164938062}
    15.  
    5. Open MyPrefab and modity the position.
    6. Save it.


    prefab property is None for MySO in Inspector panel

    flowing error log in console.
    Code (CSharp):
    1.  
    2. AssetImporter is referencing an asset from the previous import. This should not happen.
    3. UnityEditor.EditorApplication:Internal_CallGlobalEventHandler()
    4.  
    flowing yaml in MyPrefab.prefab

    Code (CSharp):
    1.  
    2. --- !u!114 &114721633881386746
    3. MonoBehaviour:
    4.   m_ObjectHideFlags: 0
    5.   m_CorrespondingSourceObject: {fileID: 0}
    6.   m_PrefabInstance: {fileID: 0}
    7.   m_PrefabAsset: {fileID: 0}
    8.   m_GameObject: {fileID: 0}
    9.   m_Enabled: 1
    10.   m_EditorHideFlags: 0
    11.   m_Script: {fileID: 11500000, guid: 40b994cea1c45b64683d08d6cb75bb44, type: 3}
    12.   m_Name: MySo
    13.   m_EditorClassIdentifier:
    14.   prefab: {fileID: 5928805271164938062, guid: cd7bea1403b5b8249b137f72cddbd1ff, type: 3}
    15.  
    7. modify the position and save it again.

    MyPrefab.prefab change following, notice the prefab property.

    Code (CSharp):
    1.  
    2. --- !u!114 &114721633881386746
    3. MonoBehaviour:
    4.   m_ObjectHideFlags: 0
    5.   m_CorrespondingSourceObject: {fileID: 0}
    6.   m_PrefabInstance: {fileID: 0}
    7.   m_PrefabAsset: {fileID: 0}
    8.   m_GameObject: {fileID: 0}
    9.   m_Enabled: 1
    10.   m_EditorHideFlags: 0
    11.   m_Script: {fileID: 11500000, guid: 40b994cea1c45b64683d08d6cb75bb44, type: 3}
    12.   m_Name: MySo
    13.   m_EditorClassIdentifier:
    14.   prefab: {fileID: 0}
    15.  



    yaml file change flow:

    1. drag asset to prefab property, and save.
    Code (CSharp):
    1. prefab: {fileID: 5928805271164938062}
    2. modify the prefab and save.
    log error in console panel.
    Code (CSharp):
    1. prefab: {fileID: 5928805271164938062, guid: cd7bea1403b5b8249b137f72cddbd1ff, type: 3}
    3. modity the prefab again and save.
    Code (CSharp):
    1. prefab: {fileID: 0}


    upload_2018-10-12_11-11-27.png
     
  2. runevision

    runevision

    Unity Technologies

    Joined:
    Nov 28, 2007
    Posts:
    1,673
    Sorry, I find this hard to understand. You're not describing with words what the issue is, or what the expected versus actual result is, and that makes it hard to follow what you're trying to convey with all the snippets and the image. Can you file a bug report with repro project and repro steps please?
     
    adarshabn likes this.
  3. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    729
    It looks like he's reporting a case where a Unity-internal check message similar to an assert failure. "AssetImporter is referencing an asset from the previous import. This should not happen."
     
  4. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    4,392
    It seems like adding a ScriptableObject to a prefab through AssetDatabase.AddObjectToAsset, and then assigning that prefab to that SO makes the serializer all kinds of confused.

    If you look at the different yaml files, it's jumping between how the prefab is referenced between each time something unrelated (the position value of the prefab) is changed.
     
  5. litefeel

    litefeel

    Joined:
    Dec 6, 2016
    Posts:
    45
    I'm sorry for my bad English.
    I'm report an issue via unity editor.
    I push a repository to github https://github.com/litefeel/PrefabRefByInsideSO


    What happened?
    Prefab cannot be referenced by internal ScriptObject when the prefab any change and save.

    How we can reproduce it using the example you attached?
    1. Drag MyPrefab to MySo's prefab property
    2. Save it.
    3. Open MyPrefab and modify anything and save it.
    4. MySo's prefab property is Null
     
  6. SteenLund

    SteenLund

    Unity Technologies

    Joined:
    Jan 20, 2011
    Posts:
    452
    Hi,

    Have you filed a bug for this issue?
    I have an idea of what it going on, but I would like to have the issue tracked so I don't forget to have a look at it.
     
  7. litefeel

    litefeel

    Joined:
    Dec 6, 2016
    Posts:
    45
    Hi.

    Yes.
    The case id is 1090541
    Title is (Open) Prefab cannot be referenced by inside ScriptObject
     
    runevision likes this.
  8. SteenLund

    SteenLund

    Unity Technologies

    Joined:
    Jan 20, 2011
    Posts:
    452
    Great. Thank you
     
  9. litefeel

    litefeel

    Joined:
    Dec 6, 2016
    Posts:
    45
    Hi.
    Is this bug handled? It seems that there are no updates.
     
  10. SteenLund

    SteenLund

    Unity Technologies

    Joined:
    Jan 20, 2011
    Posts:
    452
    The issue has been fixed and is currently in the release queue. Hopefully that means next week.
     
    P_Jong likes this.
  11. litefeel

    litefeel

    Joined:
    Dec 6, 2016
    Posts:
    45
    Thanks.
     
  12. litefeel

    litefeel

    Joined:
    Dec 6, 2016
    Posts:
    45
    Hi.
    This bug have not fiexed in unity2018.3.0b11.

    Do you mean 2018.3.0b12?

    Thanks.
     
  13. nsfnotthrowingaway

    nsfnotthrowingaway

    Joined:
    Feb 18, 2016
    Posts:
    45
    @litefeel - it's not ideal, but the temporary workaround I'm using is to make a variant of the prefab, and set their prefab properties to eachother.

    For example:
    set MySo's prefab property to MySoVariant
    and set MySoVariants's prefab property to MySo
     
  14. litefeel

    litefeel

    Joined:
    Dec 6, 2016
    Posts:
    45
    Thanks.
    I split myso into another file with the same name as prefab.

    https://issuetracker.unity3d.com/product/unity/issues/guid/1090541/
    Hi. When can you fix it?
     
  15. kubajs

    kubajs

    Joined:
    Apr 18, 2015
    Posts:
    53
    I was able to fix the issue by moving the prefab to the hierarchy temporarily, setting the reference in the hierarchy and applying the prefab changes. Not 100% sure whether you had the same case so ignore me if this is irrelevant to your case. Still not completely familiar with the new prefab system.
     
  16. zayyeh

    zayyeh

    Joined:
    Oct 18, 2016
    Posts:
    4
    Hi, kubajs, could you please elaborate on your answer? How do I get rid of this error?
     
  17. SteenLund

    SteenLund

    Unity Technologies

    Joined:
    Jan 20, 2011
    Posts:
    452
    There were a few corner cases in this workflow that was not covered by the first fix. More fixes are coming in a future patch release.
     
  18. kubajs

    kubajs

    Joined:
    Apr 18, 2015
    Posts:
    53
    In my case the workaround was I drag & dropped the prefab to project hierarchy, edited the prefab instance in there and then applied the changes to prefab.
    When I made the change directly in prefab, it hasn't been persisted so I then tried the described solution based on this thread.
     
  19. zayyeh

    zayyeh

    Joined:
    Oct 18, 2016
    Posts:
    4
    Seems like 2019.2.0a9 fixed this issue for me.
     
  20. Nomibuilder

    Nomibuilder

    Joined:
    Apr 24, 2014
    Posts:
    19
    Is this issue causing any crashes in android devices?
    can we ignore it?
    I am facing this in Unity2019.1.3f1
     
  21. cardcastleusa

    cardcastleusa

    Joined:
    Mar 20, 2018
    Posts:
    6
    This error occurred for me while referencing a variant prefab within the original prefab or vise versa.

    Game works just fine in the editor while testing, haven't built into a stand alone yet.

    If error persists I might just make all variants stand alone prefabs.
     
  22. harleydk

    harleydk

    Joined:
    Jul 30, 2012
    Posts:
    2
    Got this error on a brand-spanking new 2019.1.7f1 project, nothing in there but the Oculus Integration asset.
     
  23. chrisjfarr

    chrisjfarr

    Joined:
    Feb 17, 2018
    Posts:
    2
    Unity devs, is there anyway with some of these errors that you could append the asset path to the message in the console window? I have nearly 500 different assets in my project, and I have no idea which one is causing this error to come up repeatedly. Thanks, and great game engine otherwise!