private void OnPreprocessAsset() { if (!assetImporter.importSettingsMissing) { return; } if (!IsPresetAsset(assetImporter.assetPath)) { return; } string path = Path.GetDirectoryName(assetPath); if (string.IsNullOrEmpty(path)) { return; } if (!PresetManagerStorage.IsInstanceAvailable()) { return; } PresetManagerUtils.ApplySettingsToAsset(path, assetImporter); }
private static void GetOrCreateInstance() { if (instance != null) { return; } string[] avaialbleGUIDs = AssetDatabase.FindAssets("t:PresetManagerStorage"); if (avaialbleGUIDs.Length == 0) { string directoryPath = Path.GetDirectoryName(Path.GetFullPath(DEFAULT_STORAGE_PATH)); if (!Directory.Exists(directoryPath)) { Directory.CreateDirectory(directoryPath); } instance = CreateInstance <PresetManagerStorage>(); AssetDatabase.CreateAsset(instance, DEFAULT_STORAGE_PATH); AssetDatabase.SaveAssets(); } else { instance = AssetDatabase.LoadAssetAtPath <PresetManagerStorage>( AssetDatabase.GUIDToAssetPath(avaialbleGUIDs[0])); ValidateInstances(); } }
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) { if (!PresetManagerStorage.IsInstanceAvailable()) { return; } if (IsPresetAsset(importedAssets) || IsPresetAsset(deletedAssets)) { PresetManagerUtils.ProjectPresetsChanged(); return; } }
private void OnEnable() { presetManagerStorage = (PresetManagerStorage)target; }