Search Unity

  1. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  2. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  3. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  4. Participate with students all over the world and build projects to teach people. Join now!
    Dismiss Notice
  5. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  6. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  7. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

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

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

  1. litefeel

    litefeel

    Joined:
    Dec 6, 2016
    Posts:
    37
    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,378
    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:
    451
    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:
    3,465
    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:
    37
    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:
    319
    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:
    37
    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:
    319
    Great. Thank you
     
  9. litefeel

    litefeel

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

    SteenLund

    Unity Technologies

    Joined:
    Jan 20, 2011
    Posts:
    319
    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:
    37
    Thanks.
     
  12. litefeel

    litefeel

    Joined:
    Dec 6, 2016
    Posts:
    37
    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:
    37
    @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:
    37
    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?