| 12345678910111213141516171819202122232425262728293031323334353637 |
- using UnityEditor;
- namespace DunGen.Editor
- {
- public sealed class CreateDunGenSettings : AssetPostprocessor
- {
- #if UNITY_2021_2_OR_NEWER
- static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths, bool didDomainReload)
- {
- // Ignore if we're importing the DunGenSettings asset to avoid an infinite loop
- foreach (var path in importedAssets)
- {
- var assetType = AssetDatabase.GetMainAssetTypeAtPath(path);
- if (assetType == typeof(DunGenSettings))
- return;
- }
- DunGenSettings.FindOrCreateInstanceAsset();
- }
- #else
- static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
- {
- // Ignore if we're importing the DunGenSettings asset to avoid an infinite loop
- foreach (var path in importedAssets)
- {
- var assetType = AssetDatabase.GetMainAssetTypeAtPath(path);
- if (assetType == typeof(DunGenSettings))
- return;
- }
- DunGenSettings.FindOrCreateInstanceAsset();
- }
- #endif
- }
- }
|