public void SetGenerateCustomStaticFileName(ScriptableObjectCollection targetCollection, string targetName) { CollectionToSettings settings = GetOrCreateSettingsForCollection(targetCollection); settings.customStaticFileName = targetName; ObjectUtility.SetDirty(this); }
public void ValidateGUIDs() { for (int i = 0; i < collections.Count; i++) { ScriptableObjectCollection collectionA = collections[i]; for (int j = 0; j < collections.Count; j++) { ScriptableObjectCollection collectionB = collections[j]; if (i == j) { continue; } if (string.Equals(collectionA.GUID, collectionB.GUID, StringComparison.OrdinalIgnoreCase)) { collectionB.GenerateNewGUID(); ObjectUtility.SetDirty(collectionB); Debug.LogWarning( $"Found duplicated collection GUID, please regenerate code of collection {collectionB.name}", this ); } } collectionA.ValidateGUIDs(); } }
public void SetStaticFileFolderForCollection(ScriptableObjectCollection targetCollection, string targetFolder) { CollectionToSettings settings = GetOrCreateSettingsForCollection(targetCollection); settings.staticGeneratedFileParentFolder = targetFolder; ObjectUtility.SetDirty(this); }
public void SetGenerateCustomStaticFile(ScriptableObjectCollection targetCollection, bool isUsingCustom) { CollectionToSettings settings = GetOrCreateSettingsForCollection(targetCollection); settings.generateCustomStaticFile = isUsingCustom; ObjectUtility.SetDirty(this); }
public void SetCollectionAutomaticallyLoaded(ScriptableObjectCollection targetCollection, bool isAutomaticallyLoaded) { CollectionToSettings settings = GetOrCreateSettingsForCollection(targetCollection); settings.isAutomaticallyLoaded = isAutomaticallyLoaded; ObjectUtility.SetDirty(this); }
public void SetStaticFileGeneratorTypeForCollection(ScriptableObjectCollection targetCollection, GeneratedStaticFileType staticCodeGeneratorType) { CollectionToSettings settings = GetOrCreateSettingsForCollection(targetCollection); settings.generatedStaticFileGeneratorType = staticCodeGeneratorType; ObjectUtility.SetDirty(this); }
public void SetOverridingStaticFileLocation(ScriptableObjectCollection collection, bool isOverriding) { CollectionToSettings settings = GetOrCreateSettingsForCollection(collection); settings.overrideStaticFileLocation = isOverriding; ObjectUtility.SetDirty(this); }
public void ReloadCollections() { #if UNITY_EDITOR if (Application.isPlaying) { return; } string[] collectionsGUIDs = UnityEditor.AssetDatabase.FindAssets($"t:{nameof(ScriptableObjectCollection)}"); collections.Clear(); collectionGUIDs.Clear(); for (int i = 0; i < collectionsGUIDs.Length; i++) { string collectionGUID = collectionsGUIDs[i]; ScriptableObjectCollection collection = UnityEditor.AssetDatabase.LoadAssetAtPath <ScriptableObjectCollection>( UnityEditor.AssetDatabase.GUIDToAssetPath(collectionGUID)); if (collection == null) { continue; } collection.RefreshCollection(); collections.Add(collection); collectionGUIDs.Add(collection.GUID); } ObjectUtility.SetDirty(this); #endif }
public static void RenameAsset(Object targetObject, string newName) { #if UNITY_EDITOR targetObject.name = newName; UnityEditor.AssetDatabase.RenameAsset(UnityEditor.AssetDatabase.GetAssetPath(targetObject), newName); ObjectUtility.SetDirty(targetObject); #endif }
public void PreBuildProcess() { RemoveNonAutomaticallyInitializedCollections(); ObjectUtility.SetDirty(this); #if UNITY_EDITOR UnityEditor.AssetDatabase.SaveAssets(); #endif }
private void SyncGUID() { if (!string.IsNullOrEmpty(guid)) { return; } guid = Guid.NewGuid().ToString(); #if UNITY_EDITOR guid = UnityEditor.AssetDatabase.AssetPathToGUID(UnityEditor.AssetDatabase.GetAssetPath(this)); ObjectUtility.SetDirty(this); #endif }
private void OnDisable() { if (collection == null) { return; } for (int i = 0; i < collection.Items.Count; i++) { ObjectUtility.SetDirty(collection.Items[i]); } ObjectUtility.SetDirty(collection); }
private void DrawDeleteButton(CollectableScriptableObject item) { Color previousColor = GUI.backgroundColor; GUI.backgroundColor = CollectionEditorGUI.DELETE_BUTTON_COLOR; if (GUILayout.Button(CollectionEditorGUI.X_CHAR, EditorStyles.miniButton, GUILayout.Width(30), CollectionEditorGUI.DEFAULT_HEIGHT)) { int index = collection.IndexOf(item); collection.RemoveAt(index); AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(item)); ObjectUtility.SetDirty(collection); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); filteredItemListDirty = true; } GUI.backgroundColor = previousColor; }
public void ReloadCollections() { #if UNITY_EDITOR if (Application.isPlaying) { return; } collections.Clear(); bool changed = false; List <Type> types = TypeUtility.GetAllSubclasses(typeof(ScriptableObjectCollection)); for (int i = 0; i < types.Count; i++) { Type type = types[i]; string[] typeGUIDs = AssetDatabase.FindAssets($"t:{type.Name}"); for (int j = 0; j < typeGUIDs.Length; j++) { string typeGUID = typeGUIDs[j]; ScriptableObjectCollection collection = AssetDatabase.LoadAssetAtPath <ScriptableObjectCollection>(AssetDatabase.GUIDToAssetPath(typeGUID)); if (collection == null) { continue; } collection.RefreshCollection(); collections.Add(collection); changed = true; } } if (changed) { ObjectUtility.SetDirty(this); } ValidateGUIDs(); #endif }
public void RemoveNonAutomaticallyInitializedCollections() { #if UNITY_EDITOR for (int i = collections.Count - 1; i >= 0; i--) { ScriptableObjectCollection collection = collections[i]; SerializedObject serializedObject = new SerializedObject(collection); SerializedProperty automaticallyLoaded = serializedObject.FindProperty("automaticallyLoaded"); if (automaticallyLoaded.boolValue) { continue; } collections.Remove(collection); } ObjectUtility.SetDirty(this); #endif }
public void DeleteCollection(ScriptableObjectCollection collection) { if (Application.isPlaying) { return; } if (!collections.Remove(collection)) { return; } collectionGUIDs.Remove(collection.GUID); #if UNITY_EDITOR for (int i = collection.Items.Count - 1; i >= 0; i--) { UnityEditor.AssetDatabase.DeleteAsset(UnityEditor.AssetDatabase.GetAssetPath(collection.Items[i])); } #endif ObjectUtility.SetDirty(this); }
private void DrawEditFoldoutButton(ref Rect popupRect, ScriptableObjectCollectionItem targetItem) { Rect buttonRect = popupRect; buttonRect.width = 30; buttonRect.height = 18; popupRect.width -= buttonRect.width; buttonRect.x += popupRect.width; GUIContent guiContent = CollectionEditorGUI.EditGUIContent; if (CollectionUtility.IsFoldoutOpen(targetItem, currentObject)) { guiContent = CollectionEditorGUI.CloseGUIContent; } if (GUI.Button(buttonRect, guiContent)) { CollectionUtility.SetFoldoutOpen(!CollectionUtility.IsFoldoutOpen(targetItem, currentObject), targetItem, currentObject); ObjectUtility.SetDirty(targetItem); } }
private void DrawEditFoldoutButton(ref Rect popupRect) { Rect buttonRect = popupRect; buttonRect.width = 30; buttonRect.height = 18; popupRect.width -= buttonRect.width; buttonRect.x += popupRect.width; GUIContent guiContent = CollectionEditorGUI.EditGUIContent; if (CollectionUtility.IsFoldoutOpen(foldoutObject)) { guiContent = CollectionEditorGUI.CloseGUIContent; } if (GUI.Button(buttonRect, guiContent)) { CollectionUtility.SetFoldoutOpen(foldoutObject, !CollectionUtility.IsFoldoutOpen(foldoutObject)); ObjectUtility.SetDirty(collectableItem); } }
public void SetCollection(ScriptableObjectCollection collection) { this.collection = collection; ObjectUtility.SetDirty(this); }
public void SetCollection(ScriptableObjectCollection collection) { cachedScriptableObjectCollection = collection; collectionGUID = cachedScriptableObjectCollection.GUID; ObjectUtility.SetDirty(this); }