7public class StepItemPostprocessor : AssetPostprocessor
9 private static void OnPostprocessAllAssets(
10 string[] importedAssets,
11 string[] deletedAssets,
13 string[] movedFromAssetPaths
16 bool validateScenario =
false;
18 for (
int i = 0; i < deletedAssets.Length; i++)
20 var asset = deletedAssets[i];
22 if (asset.Contains(ScenarioEditorWindow.ScenariosRootPath))
24 CheckScenarioData(asset);
25 validateScenario =
true;
29 for (
int i = 0; i < movedAssets.Length; i++)
31 var asset = movedAssets[i];
33 if (asset.Contains(ScenarioEditorWindow.ScenariosRootPath))
35 CheckScenarioData(asset);
36 validateScenario =
true;
40 for (
int i = 0; i < movedFromAssetPaths.Length; i++)
42 var asset = movedFromAssetPaths[i];
44 if (asset.Contains(ScenarioEditorWindow.ScenariosRootPath))
46 CheckScenarioData(asset);
47 validateScenario =
true;
51 for (
int i = 0; i < importedAssets.Length; i++)
53 var asset = importedAssets[i];
55 if (asset.Contains(ScenarioEditorWindow.ScenariosRootPath))
57 CheckScenarioData(asset);
58 validateScenario =
true;
64 string[] guids = AssetDatabase.FindAssets(
68 Path.GetDirectoryName(ScenarioEditorWindow.ScenariosRootPath)
72 foreach (
string guid
in guids)
74 AssetDatabase.LoadAssetAtPath<
ScenariosDataSO>(AssetDatabase.GUIDToAssetPath(guid))?.Validate();
79 private static void CheckScenarioData(
string asset)
81 var directory = Path.GetDirectoryName(asset);
83 if (directory.Contains(ScenarioEditorWindow.StepsDirectoryName))
85 string[] guids = AssetDatabase.FindAssets(
"t:StepsDataSO",
new[] {Path.GetDirectoryName(directory)});
87 foreach (
string guid
in guids)
89 var stepsData = AssetDatabase.LoadAssetAtPath<
StepsDataSO>(AssetDatabase.GUIDToAssetPath(guid));