public void Add(IEditorCommand cmd) { if (cmd == null) { return; } //移除当前命令之后的所有已执行命令 int removeNum = cmdList.Count - currCount; if (removeNum > 0) { cmdList.RemoveRange(currCount, removeNum); } //Modify by liteng for MoveAtlas At 2014/1/4 NotifyBeforeCmdExecute(cmd, removeNum); cmd.Execute(); //Modify by liteng for MoveAtlas At 2014/1/4 NotifyAfterCmdExecute(cmd, removeNum); if (cmd.DontSaved || useUnityUndo) {//命令本身为只执行不保存的或只使用Unity Undo cmdList.Add(cmd); currCount++; } NotifyChange(); }
public void NotifyAfterCmdExecute(IEditorCommand cmd, int removeCmdCount) { if (onAfterCmdExecute != null) { onAfterCmdExecute(cmd, removeCmdCount); } }
//Modify by liteng for MoveAtlas At 2014/1/4 public void OnAfterCmdExecute(IEditorCommand cmd, int removeCmdCount) { if (!HasEditTarget()) { return; } SpecialEffectEditorUtility.MarkSpecialEffectDirty(GetEditTarget().RealSpe); }
/* * 对Command函数的响应函数 */ //Modify by liteng for MoveAtlas At 2014/1/4 public void OnBeforeCmdExecute(IEditorCommand cmd, int removeCmdCount) { if (!HasEditTarget()) { return; } //GetEditTarget()._DebugPrintElemTimes(); SpecialEffectEditorUtility.UndoRecordSpecialEffect(cmd, GetEditTarget().RealSpe); }
/// <summary> /// Is responsible for the correct work off of the key the user pressed. /// </summary> /// <param name="sender">The sending object.</param> /// <param name="eventArgs">The key the user pressed.</param> /// <exception cref="ArgumentNullException"> /// If eventArgs is null. /// </exception> public void UseKey(object sender, OnKeyPressedEventArgs eventArgs) { if (eventArgs == null) { throw new ArgumentNullException(); } ConsoleKeyInfo cki = eventArgs.KeyInfo; switch (cki.Key) { case ConsoleKey.Enter: if (!string.IsNullOrWhiteSpace(this.handler.Text)) { IEditorCommand command = this.parser.Parse(this.handler.Text); this.errorMessage.Message = string.Empty; if (command == null) { this.errorMessage.Message = "This is not a valid command."; } else { try { this.handler.Text = string.Empty; this.handler.Accept(command); this.user.Accept(command); } catch { this.errorMessage.Accept(command); } } } if (this.user.EditingIsFinished) { this.keyBoardWatcher.OnKeyPressed -= this.UseKey; this.InitializeExecution(); this.keyBoardWatcher.OnKeyPressed += this.CheckIfExecutionersFinished; } break; default: this.errorMessage.Message = string.Empty; this.handler.Start(cki); break; } this.handler.Accept(this.editorRenderer); this.errorMessage.Accept(this.editorRenderer); }
public void ExecuteCommand(IEditorCommand command) { _compositionChangedByCommand = true; var args = ConstructCommandArgs(); if (command.CanExecute(args)) { command.Execute(args); } _compositionChangedByCommand = false; }
public void Do(IEditorCommand cmd) { cmd.Do(); UndoStack.Push(cmd); RedoStack.Clear(); if (cmd.IsDestructive) { EditCount++; } }
public void Do(Material targetMaterial, IEditorCommand command) { if (targetMaterial is null) { return; } Commanders[targetMaterial].Do(command); if (command.IsDestructive) { IsSended = false; } UpdateDraw?.Invoke(); }
public void Execute(IEditorCommand cmd) { if (cmd == null) { return; } cmd.Execute(); if (currCmdIndx == -1) { cmdList.Clear(); } else { cmdList.RemoveRange(currCmdIndx + 1, cmdList.Count - currCmdIndx - 1); } cmdList.Add(cmd); currCmdIndx++; }
public static void UndoRecordSpecialEffect(IEditorCommand cmd, SpecialEffect spe) { if (Application.isPlaying) { return; } List <UnityEngine.Object> objList = new List <UnityEngine.Object>(); foreach (var e in spe.elems) { objList.Add(e); } objList.Add(spe); #if UNITY_4_5 || UNITY_4_6 || UNITY_5_0 || UNITY_5_1 Undo.RegisterCompleteObjectUndo(objList.ToArray(), cmd.Name); #else Undo.RecordObjects(objList.ToArray(), cmd.Name); #endif }
private void ExtensionRegistered(IEditorCommand command) { Commands.Add(command); }
public bool CanCommandExecute(IEditorCommand command) { var args = ConstructCommandArgs(); return(command.CanExecute(args)); }
public void ExecuteCommand(IEditorCommand command) { // dummy }
public bool CanCommandExecute(IEditorCommand command) => false;