Search Unity

Could not extract GUID in text file error after upgrading to 2018.2.3f1

Discussion in 'Editor & General Support' started by wagenheimer, Aug 17, 2018.

  1. wagenheimer

    wagenheimer

    Joined:
    Jun 1, 2018
    Posts:
    323
    Hi!

    After upgrading older projects to Unity 2018.2.3f1, I got tons of these kinds of errors when opening a scene or making a build.

    Code (csharp):
    1.  
    2. Could not extract GUID in text file Assets/_Game/Scenes/level.unity at line 1964.
    3. Could not extract GUID in text file Assets/_Game/Scenes/level.unity at line 4405.
    4.  
    Besides that, everything seems to work fine and this error seems to not break anything.

    But, how I can fix them? Anybody faced something similar?
     
  2. wagenheimer

    wagenheimer

    Joined:
    Jun 1, 2018
    Posts:
    323
  3. unity_yUAfSYVSfFt1sA

    unity_yUAfSYVSfFt1sA

    Joined:
    Aug 31, 2018
    Posts:
    5
    Same here, when changed any objects they will be 2018.2.6f1
     
  4. threeguysgamestudio

    threeguysgamestudio

    Joined:
    Dec 1, 2017
    Posts:
    25
    Same problem, bump
     
  5. wagenheimer

    wagenheimer

    Joined:
    Jun 1, 2018
    Posts:
    323
    I don't remember what I have done but I fixed them all. But now a friend is facing the same problem and could not solve it.

    Anybody else fixed this and could remember the steps to fix?
     
  6. threeguysgamestudio

    threeguysgamestudio

    Joined:
    Dec 1, 2017
    Posts:
    25
    Nope, they are still popping up in my scenes on the reg.
     
  7. BusyRoots

    BusyRoots

    Joined:
    Jul 25, 2017
    Posts:
    41
    I experience the GUID errors as well (working with Unity version 2018.3.6f1). So I created a minimal example in a test scene to reliable reproduce the error. The error says:

    Could not extract GUID in text file Assets/Scenes/Test.unity at line 234.
    UnityEditor.EditorApplication:Internal_CallGlobalEventHandler()


    I found out that the problem in my case is the interaction between a prefab gameobject called SpriteAtlasTest that has the following components: a sprite renderer and a script TestSpriteAtlas.cs that holds a sprite atlas. I have also an editor script TestSpriteAtlasEditor.cs to create a button in the inspector.

    The button calls a method in the TestSpriteAtlas.cs that gets a sprite out of the atlas (by the name of the sprite) to assign it to the sprite renderer. Background: I have a Tree prefab with different grow stages and want to load according to the set grow stage the corresponding sprite + this should be possible in editor mode to make level design easier.

    Here is what happens: In editor mode I hit the button and the right sprite is loaded and displayed. No error so far. If I now make some changes in the scene with this prefab e.g. change the position and save the scene everything is still fine but if I do it a second time than the GUID error occurs.

    If I open the scene file Test.unity (YAML) which is referenced in the log I see this:

    texture: {fileID: 2, guid: 00000000000000000000000000000000, type: 0}


    This line is part of the component m_AtlasRD see screenshot: GUID_Error_in_Test_Scene.
    If I change the line above to:

    texture: {fileID: 2}


    the error is gone but it comes back if I move the prefab around in the scene again and save the scene. The error is also displayed right after the starting Unity.

    For further investigations I also look in my git change log after the error appears (made a commit in error free state before). There I see the expected changed position of the prefab in the scene but also that the were some changes in the binary file assetDatabase3 (see screneshot: Test_scene_changes_after_GUID_error_appears). Unfortunately this file is not readable.

    My unsuccessful attempts (up to now) to get rid of the GUID error:
    • closing unity deleting the Library folder (file assetDatabase3 is part of that) and restart unity
    • deleting the meta files of the prefab gameobject
    • Adding some commands for updating and saving in the editor script:
      serializedObject.Update(), serializedObject.ApplyModifiedProperties(), EditorUtility.SetDirty(mySpriteAtlasObjectTest)
      to the editor script (see comments in code below)
    So the error clearly has something to do with the sprite atlas. It only appears if i load a sprite out of the atlas in editor mode. I assume it has something to do with sprite clone that is created and assigned to the sprite renderer but I'm not sure why that happens.

    Has anybody an idea how I could fix the problem or what causes the error???



    See below the code of the MonoBehaviour and the Editor script:

    TestSpriteAtlas.cs

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.U2D;
    3.  
    4. public class TestSpriteAtlasObject : MonoBehaviour
    5. {
    6.  
    7.     public SpriteAtlas TestAtlas;
    8.     //public Tree TestTree;
    9.  
    10.     private SpriteRenderer _spriteRenderer;
    11.  
    12.     // Start is called before the first frame update
    13.     void Start()
    14.     {
    15.         _spriteRenderer = GetComponent<SpriteRenderer>();
    16.  
    17.         _spriteRenderer.sprite = TestAtlas.GetSprite("AleppoPine_WateredGround");
    18.  
    19.         ChangeSpriteToWateredGround();
    20.     }
    21.  
    22.  
    23.     public void ChangeSpriteToWateredGround()
    24.     {
    25.         _spriteRenderer = GetComponent<SpriteRenderer>();
    26.  
    27.         _spriteRenderer.sprite = TestAtlas.GetSprite("AleppoPine_WateredGround");
    28.     }
    29.  
    30. }

    TestSpriteAtlasEditor.cs

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEditor;
    3.  
    4. [CustomEditor(typeof(TestSpriteAtlasObject), true)]
    5. public class SpriteAtlasTestEditor : Editor
    6. {
    7.     // On Inspector GUI
    8.     public override void OnInspectorGUI()
    9.     {
    10.         DrawDefaultInspector();
    11.  
    12.         TestSpriteAtlasObject mySpriteAtlasObjectTest = (TestSpriteAtlasObject) target;
    13.  
    14.         // button in inspector
    15.         if (GUILayout.Button("Set Watered Ground Sprite"))
    16.         {
    17.             mySpriteAtlasObjectTest.ChangeSpriteToWateredGround();
    18.  
    19.             //serializedObject.Update();
    20.         }
    21.  
    22.         // applies custom changes made in the inspector in unity
    23.         //serializedObject.ApplyModifiedProperties();
    24.  
    25.         // when pressing Strg + S all made changes are saved
    26.         // see https://answers.unity.com/questions/927689/scriptableobject-asset-not-saved-to-disk.html
    27.         //EditorUtility.SetDirty(mySpriteAtlasObjectTest);
    28.     }
    29. }
     

    Attached Files:

    Last edited: Feb 28, 2019
  8. BusyRoots

    BusyRoots

    Joined:
    Jul 25, 2017
    Posts:
    41
    Update: the sprite packer mode in unity (project settings/editor) is set to Always Enabled if I set it to Always Enabled (Legacy Sprite Packer) the GUID errors disappear but the sprites aren't loaded in play mode.
     
    hajimamad likes this.
  9. Rafarel

    Rafarel

    Joined:
    Jul 21, 2017
    Posts:
    199
    Hello there, I have the same problem here !
    I don't know what object causes the issue, but this is critical !
    Please help ;)
     
  10. BusyRoots

    BusyRoots

    Joined:
    Jul 25, 2017
    Posts:
    41
    @Rafarel I still have the GUID but my advice for starters would be to take a look at the mentioned line in the GUID Error message in your <SceneName>.unity file and the content around. Maybe this gives you a hint.
     
  11. BusyRoots

    BusyRoots

    Joined:
    Jul 25, 2017
    Posts:
    41
    I ended up switching from spritesheets to reading the sprites in from the Texture2D (e.g. .png) and saving the information into two lists: one list with the actual sprites (value) and one with the sprite names (keys) (like a dictionary, but dictionary can not be serialized that's why I had to use two lists instead).
     
  12. jweidenbach

    jweidenbach

    Joined:
    Dec 29, 2018
    Posts:
    54
    My suspicion on this (I'm running into it as well) is that Unity is serializing the .sprite property (in my case it's on an image component). My prefab editor is showing scene overrides on the .sprite format, and because the image being assigned is coming from a SpriteAtlas, the GUID is null at read-time. I'm currently falling back to _not_ having the sprite shown in edit mode, but this is annoying nonetheless. My current take is that I need to either write my own Image class that won't serialize the sprite property, or just give up on uGUI and go back to ezGUI.
     
  13. Riddhesh

    Riddhesh

    Joined:
    Jan 5, 2015
    Posts:
    4
    I don't know how exactly I got this problem solved, I just hit "Apply' on all prefabs and this problem solved for me. It was very frustrating I was not able to find much info / solution about this on internet. But I remember I started getting this problem after I had made some changes in prefabs.
     
  14. Alex-Simson

    Alex-Simson

    Joined:
    Nov 18, 2013
    Posts:
    1
    Saving a scene under another name, deleting the old one and renaming it back helped me.
     
    kandreev42, sebj, FunRobDev and 2 others like this.
  15. FunRobDev

    FunRobDev

    Joined:
    Jun 3, 2017
    Posts:
    11
    I had this error several times (Unity 2018.4.14f - Unity 2019.3.5f), and nothing helped but editing the unity file in a text editor. I think there can be several variations of this error and can be more reasons why this error happens but seems, that Unity Editor sometimes messes up something with sprites and spriteatlases.
    For me the following happened, and I tell you how I fixed it.

    Before doing anything, I made a backup copy of the unity file.

    Unity Editor reported that it cant extract the GUID 000000000000000000000 in line #154435. (see my copied unity file part below) Ok, I inspected what is that. When you search upwards from there you can find the GameObject what has this faulty component. See I have this gameobject called PuckBackGlowRectangle, and we can see, it has 3 components with the orange, green, and brown ids, and they are referenced to an existing component below with those ids, see below.

    But the problem is - I found out - that the faulty component (purple lines) which has the GUID 0000000000000000 in it, is not referenced by the GameObject PuckBackGlowRectangle at all! So it is an invisible faulty component, which you can't see in the Unity Editor (This component seems to try to extract some sprite from an old not existing sprite atlas). So I deleted the purple lines in a text-editor, and voila - one GUID error vanished. (Press CTRL+S in the editor to re-save the unity file and see the error does not appear again)

    Here are the part of my unity file (I deleted some not relevant lines to be shorter)

    --- !u!1 &387080016
    GameObject:
    m_PrefabAsset: {fileID: 0}
    m_Component:
    - component: {fileID: 387080017}
    - component: {fileID: 387080018}
    - component: {fileID: 387080019}
    m_Layer: 0
    m_Name: PuckBackGlowRectangle
    m_TagString: Untagged
    m_Icon: {fileID: 0}
    m_IsActive: 1
    --- !u!224 &387080017
    RectTransform:
    m_ObjectHideFlags: 0
    m_Pivot: {x: 0.5, y: 0.5}
    --- !u!114 &387080018
    MonoBehaviour:
    m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
    m_EditorClassIdentifier:
    --- !u!222 &387080019
    CanvasRenderer:
    m_ObjectHideFlags: 0
    --- !u!213 &387884516
    Sprite:
    m_ObjectHideFlags: 0
    bcf6b7e9c150b644bae9236dba4ed6af: 21300000
    m_AtlasTags:
    - PlayerCircleSpriteAtlas
    m_SpriteAtlas: {fileID: 4343727234628468602, guid: ddd2ac9a0a826824a83a48301b46562b, type: 2}
    m_AtlasRD:
    serializedVersion: 3
    texture: {fileID: 2, guid: 00000000000000000000000000000000, type: 0}
    alphaTexture: {fileID: 0}
    m_SpriteID: 5e97eb03825dee720800000000000000

    --- !u!1 &391911290
    GameObject:
    m_ObjectHideFlags: 0
     
    Last edited: Mar 29, 2020
  16. sevenword

    sevenword

    Joined:
    Sep 16, 2018
    Posts:
    1
    Unity 2019.4.16f1c1 also have sameproblem,
    Code (CSharp):
    1. m_AtlasRD:
    2.     serializedVersion: 3
    3.     texture: {fileID: 2, guid: 00000000000000000000000000000000, type: 0}
    I don't know why?
     
  17. Newbies-Unity

    Newbies-Unity

    Joined:
    Nov 19, 2015
    Posts:
    22
    Just Change ProjectSetting/Editor Asset Serialization to ForceBinary and it will be gone.
     
  18. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Making this change will make your project not play nice with version control systems.
     
  19. bartje86tralala

    bartje86tralala

    Joined:
    Aug 1, 2012
    Posts:
    9
    Life is tough.

    Edit: Still present in 2021.2.0a
     
  20. HiepEldest

    HiepEldest

    Joined:
    Aug 26, 2018
    Posts:
    2
    when you load a sprite using atlas.Getsprite(spriteName), a sprite will create as a clone from atlas, not referrent to assets folder then GUID doesn't exist, so if you want to load sprite and save to scene using this
    Code (CSharp):
    1. var spriteObjects = UnityEditor.U2D.SpriteAtlasExtensions.GetPackables(atlas);
    2.                 foreach (var item in spriteObjects)
    3.                 {
    4.                     if (item.name.Equals("spriteName"))
    5.                     {
    6.                         var sprite = AssetDatabase.LoadAssetAtPath<Sprite>(AssetDatabase.GetAssetPath(item));//(Sprite)item is invalid cast!
    7.                     }
    8.                 }
    otherwise, don't make your scene dirty.
     
    byDecker likes this.
  21. chestermjr

    chestermjr

    Joined:
    Jan 16, 2018
    Posts:
    2
    For me, this error was caused by an orphaned item in the unity file. I'll try my best to explain how to fix.

    Specifically, my error was:

    Could not extract GUID in text file Assets/Scenes/World.unity at line 74488.
    Broken text PPtr. GUID 00000000000000000000000000000000 fileID 2 is invalid!


    To fix:
    1. Open the file (eg Assets/Scenes/World.unity) in a text editor.
    2. Scroll down to the line with the error (eg line 74488).
    3. Delete the entire "parent" node.
    I can elaborate on what the "parent" node is, for those who are newer to programming.

    The .unity file uses 2 spaces as an indent. To find the "parent" of an item, go up line by line in the file until you reach a line that is indented fewer spaces. In my scenario, line 74488 is the error.
    m_AtlasRD 
    on line 74486 is its parent (because it is indented fewer spaces). So delete
    m_AtlasRD 
    (line 74486) and every line beneath it that is indented more spaces, until you reach a line that is indented the same as
    m_AtlasRD
    . For me, I deleted 91 lines. The next node for me was named
    m_PhysicsShape
    .

    upload_2021-8-31_19-21-54.png
     
  22. quickndirty

    quickndirty

    Joined:
    Aug 26, 2018
    Posts:
    1
    This is my solution from a chinese website:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEditor;
    4. using UnityEditor.U2D;
    5. using UnityEngine;
    6. using UnityEngine.U2D;
    7. using UnityEngine.UI;
    8.  
    9. public class TFSprite : MonoBehaviour
    10. {
    11.     public SpriteAtlas Atlas;
    12.     public string SpriteName;
    13.  
    14.     void Start()
    15.     {
    16.         //this.GetComponent<Image>().sprite = this.Atlas.GetSprite(this.SpriteName);
    17.         this.GetComponent<Image>().sprite = GetSprite(this.Atlas, this.SpriteName);
    18.     }
    19.  
    20.     // Update is called once per frame
    21.     void Update()
    22.     {
    23.      
    24.     }
    25.  
    26.     void OnValidate()
    27.     {
    28.         this.GetComponent<Image>().sprite = GetSprite(this.Atlas, this.SpriteName);
    29.     }
    30.  
    31.     public static Sprite GetSprite(SpriteAtlas atlas, string name)
    32.     {
    33. #if UNITY_EDITOR
    34.         var packables = SpriteAtlasExtensions.GetPackables(atlas);
    35.         foreach (var packable in packables)
    36.         {
    37.             if (packable is Sprite)
    38.             {
    39.                 if (packable.name == name)
    40.                 {
    41.                     return (Sprite)packable;
    42.                 }
    43.             }
    44.             else if (packable is Texture2D)
    45.             {
    46.                 var dirPath = AssetDatabase.GetAssetPath(packable);
    47.                 var spriteGUIDs = AssetDatabase.FindAssets($"{name} t:sprite", new string[] { dirPath });
    48.                 if (spriteGUIDs.Length == 0)
    49.                     continue;
    50.                 var spritePath = AssetDatabase.GUIDToAssetPath(spriteGUIDs[0]);
    51.                 var sprite = AssetDatabase.LoadAssetAtPath<Sprite>(spritePath);
    52.                 return sprite;
    53.             }
    54.         }
    55.         return null;
    56. #else
    57.         return atlas.GetSprite(name);
    58. #endif
    59.     }
    60. }
     
    Aliser, ivantoth and wagenheimer like this.