campfire/Assets/Scripts/AssetModificationProcessor.cs

30 lines
841 B
C#
Raw Normal View History

using UnityEditor;
using UnityEngine;
#if UNITY_EDITOR
public class FGAssetModificationProcessor : UnityEditor.AssetModificationProcessor {
static string[] OnWillSaveAssets(string[] paths) {
foreach (GameObject obj in GameObject.FindGameObjectsWithTag("Generator")) {
Lorax Lorax = obj.GetComponent<Lorax>();
Lorax.DestroyGenerated();
}
EditorApplication.update += RefreshScene;
return paths;
}
static void RefreshScene() {
EditorApplication.update -= RefreshScene;
foreach (GameObject obj in GameObject.FindGameObjectsWithTag("Generator")) {
Lorax Lorax = obj.GetComponent<Lorax>();
2020-04-20 04:24:01 +02:00
if (Lorax.ShowInEditor) {
Lorax.DestroyGenerated();
Lorax.Generate();
}
}
}
}
#endif