Closed rhys-vdw closed 7 months 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 ()
Worked it out. It's a bug in Unity that causes the wrong path to be passed.
Perhaps only on empty folder