ogxd / project-curator

A convenient tool to help cleaning and maintaining Unity Projects 🧹✨
Do What The F*ck You Want To Public License
153 stars 27 forks source link

Warning logged when deleting folder #21

Closed rhys-vdw closed 7 months ago

rhys-vdw commented 1 year ago

Perhaps only on empty folder

ProjectCurator: Asset 'Assets/_Game/Config/Graphs/Statuses' is not present in the database
UnityEngine.Debug:LogWarning (object)
Ogxd.ProjectCurator.ProjectCurator:Warn (string) (at ./Library/PackageCache/com.ogxd.project-curator@6a70b7c196/Editor/ProjectCurator.cs:165)
Ogxd.ProjectCurator.ProjectCurator:RemoveAssetFromDatabase (string) (at ./Library/PackageCache/com.ogxd.project-curator@6a70b7c196/Editor/ProjectCurator.cs:96)
Ogxd.ProjectCurator.AssetProcessor:OnWillDeleteAsset (string,UnityEditor.RemoveAssetOptions) (at ./Library/PackageCache/com.ogxd.project-curator@6a70b7c196/Editor/AssetProcessor.cs:64)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
rhys-vdw commented 1 year ago

Looking into this now. The issue here is that the GUID is coming back empty when adding a new empty folder, even in the deferred action.

        static void OnWillCreateAsset(string assetPath)
        {
            UnityEngine.Debug.Log("Asset path: " + assetPath);
            if (ProjectCuratorData.IsUpToDate) {
                Actions.Enqueue(() => {
                    UnityEngine.Debug.Log($"Guid string is: " + AssetDatabase.AssetPathToGUID(assetPath));
                    var guid = AssetDatabase.GUIDFromAssetPath(assetPath);
                    if (!guid.Empty()) {
                        ProjectCurator.AddAssetToDatabase(guid);
                    } else {
                        UnityEngine.Debug.LogWarning($"GUID for asset at path {assetPath} is empty");
                    }
                });
            }
        }
Asset path: Assets/_Game/New Folder.meta
UnityEngine.Debug:Log (object)
Ogxd.ProjectCurator.AssetProcessor:OnWillCreateAsset (string) (at C:/Users/rhysv/Projects/project-curator/Editor/AssetProcessor.cs:49)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

Guid string is: 
UnityEngine.Debug:Log (object)
Ogxd.ProjectCurator.AssetProcessor/<>c__DisplayClass4_0:<OnWillCreateAsset>b__0 () (at C:/Users/rhysv/Projects/project-curator/Editor/AssetProcessor.cs:52)
Ogxd.ProjectCurator.AssetProcessor:OnUpdate () (at C:/Users/rhysv/Projects/project-curator/Editor/AssetProcessor.cs:25)
UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()

GUID for asset at path Assets/_Game/New Folder.meta is empty
UnityEngine.Debug:LogWarning (object)
Ogxd.ProjectCurator.AssetProcessor/<>c__DisplayClass4_0:<OnWillCreateAsset>b__0 () (at C:/Users/rhysv/Projects/project-curator/Editor/AssetProcessor.cs:57)
Ogxd.ProjectCurator.AssetProcessor:OnUpdate () (at C:/Users/rhysv/Projects/project-curator/Editor/AssetProcessor.cs:25)
UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()
rhys-vdw commented 1 year ago

Worked it out. It's a bug in Unity that causes the wrong path to be passed.