본문 바로가기
개발/Unity

문제해결)Unity)Could not extract GUID in text file xx

by 테샤르 2022. 1. 5.

문제해결)Could not extract GUID in text file xx

 GUID가 이상하게 꼬이는 문제가 발생했다.

 

발생원인으로 추정되는 내용은

'Unity를 재생하지 않을 때 편집기에서 SpriteAtlas에서 Sprite를 가져와서 장면을 저장을 해버려서 생겼다.'

 

Unity Project를  텍스트 기반의 장면 파일로 구성하고 있는 과정에서 실제 

해당 file을 Editor로 열어서 해당 라인으로 가면 guid: 00000000000000000000000000000000,으로 된 코드를 볼 수 있다.

반응형

 

GUID는 자산의 고유한 식별자인데 이게값은 중복되면 안 되는 값인데  guid: 00000000000000000000000000000000,으로 중복이 되게 된 경우로 해당 텍스트를 재 편집해야 한다. 

해당 guid 00000 을 삭제하고 다시 저장하면 에러가 사라진다.

 

 /// <summary>
            /// SpriteAtlas를 런타임 메모리로 처리하는 과정에서 씬을 저장할때 GUID 가 꼬이는 씬 제거하는 메뉴
            /// </summary>
            [MenuItem("Util/GUID Clear")]
            public static void GUIDClear()
            {
                List<string> scenePathList = new List<string>();
                foreach (EditorBuildSettingsScene scene in EditorBuildSettings.scenes)
                {
                    if (scene.enabled)
                        scenePathList.Add(scene.path);
                }

                //string changeString = "texture: {fileID: 0}";
                string changeString = "  texture: {fileID: 2, type: 0}";
                foreach (string str in scenePathList)
                {
                    
                    string tempPath = Application.dataPath.Replace("Assets", "") + str;
                    string[] allLines = File.ReadAllLines(tempPath);
                     
                    for (int i = 0; i < allLines.Length; ++i)
                    {
                        string lineStr = allLines[i];
                        Debug.LogVerb($"[GUID Clear] Scene  :{str} - Line {i} : {lineStr}");
                        if (lineStr.Contains("fileID:") && lineStr.Contains("guid: 00000000000000000000000000000000")) 
                        {
                            Debug.LogVerb($"[GUID Clear] Scene {str} : Line[{i}] :: {lineStr} Clear !!");
                            lineStr.Remove(0, lineStr.Length);
                            allLines[i] = changeString;
                        }
                    }
                    File.WriteAllLines(tempPath, allLines);
                }
            }

코드 원본 및 참조 : [링크]

 

[Unity IOS] Could not extract GUID in text file project/Scene.unity at line xxx

게임 개발에 대한 이야기를 나누는 블로그입니다.

today7e.blogspot.com

 

Unity 텍스트 직렬화 파일 형식 : [링크]

 

Unity - Manual: Format of Text Serialized files

Format of Text Serialized files Unity’s SceneA Scene contains the environments and menus of your game. Think of each unique Scene file as a unique level. In each Scene, you place your environments, obstacles, and decorations, essentially designing and bu

docs.unity3d.com

 

★☆☆☆☆

 

반응형

댓글