internal static void CopyToClipboard(AIUI sourceUI) { if (sourceUI.currentAction != null) { EditorGUIUtility.systemCopyBuffer = GuiSerializer.Serialize(sourceUI.currentAction); } else if (sourceUI.currentQualifier != null) { EditorGUIUtility.systemCopyBuffer = GuiSerializer.Serialize(sourceUI.currentQualifier); } else if (sourceUI.selectedViews.Count > 0) { EditorGUIUtility.systemCopyBuffer = GuiSerializer.Serialize(sourceUI.selectedViews); } }
internal void Save(string newName) { if (_ai == null || _ai.rootSelector == null) { return; } // new name is not null or empty when using 'Save As' if (!string.IsNullOrEmpty(newName)) { this.name = StoredAIs.EnsureValidName(newName, _aiStorage); // If we are saving under a new name (as opposed to saving a new AI), we need to save copy of the current AI with new Ids. if (_aiStorage != null) { _aiStorage = null; _ai.RegenerateIds(); } } bool saveNew = (_aiStorage == null); if (saveNew) { _aiStorage = AIStorage.Create(_ai.id.ToString(), this.name); StoredAIs.AIs.Add(_aiStorage); AssetPath.EnsurePath(AIGeneralSettings.instance.storagePath); var assetPath = AssetPath.Combine(AIGeneralSettings.instance.storagePath, this.name + ".asset"); AssetDatabase.CreateAsset(_aiStorage, assetPath); } _aiStorage.version = _aiVersion.version; _aiStorage.configuration = SerializationMaster.Serialize(_ai); _aiStorage.editorConfiguration = GuiSerializer.Serialize(this.canvas); EditorUtility.SetDirty(_aiStorage); AssetDatabase.SaveAssets(); this.isDirty = false; _undoRedo.SetSavePoint(); if (saveNew && UserSettings.instance.autoGenerateNameMap) { AINameMapGenerator.WriteNameMapFile(); } }
internal static void CutToClipboard(AIUI sourceUI) { if (sourceUI.currentAction != null) { EditorGUIUtility.systemCopyBuffer = GuiSerializer.Serialize(sourceUI.currentAction); sourceUI.RemoveAction(sourceUI.currentAction); } else if (sourceUI.currentQualifier != null) { if (sourceUI.currentQualifier.isDefault) { EditorUtility.DisplayDialog("Invalid Action", "The default qualifier cannot be cut. Use copy instead.", "Ok"); return; } EditorGUIUtility.systemCopyBuffer = GuiSerializer.Serialize(sourceUI.currentQualifier); sourceUI.RemoveQualifier(sourceUI.currentQualifier); } else if (sourceUI.selectedViews.Count > 0) { var selectedViews = sourceUI.selectedViews; var cutCount = selectedViews.Count; for (int i = 0; i < cutCount; i++) { var sv = selectedViews[i] as SelectorView; if (sv != null && object.ReferenceEquals(sourceUI.rootSelector, sv.selector)) { EditorUtility.DisplayDialog("Invalid Action", "The root selector can not be part of a cut operation.", "Ok"); return; } } EditorGUIUtility.systemCopyBuffer = GuiSerializer.Serialize(sourceUI.selectedViews); using (sourceUI.undoRedo.bulkOperation) { for (int i = cutCount - 1; i >= 0; i--) { sourceUI.RemoveView(selectedViews[i]); } } } }