CommandAction.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System;
  2. using UnityEngine;
  3. namespace UnityEditor.U2D.Path.GUIFramework
  4. {
  5. public class CommandAction : GUIAction
  6. {
  7. private string m_CommandName;
  8. public Action<IGUIState> onCommand;
  9. public CommandAction(string commandName)
  10. {
  11. m_CommandName = commandName;
  12. }
  13. protected override bool GetTriggerContidtion(IGUIState guiState)
  14. {
  15. if (guiState.eventType == EventType.ValidateCommand && guiState.commandName == m_CommandName)
  16. {
  17. guiState.UseEvent();
  18. return true;
  19. }
  20. return false;
  21. }
  22. protected override bool GetFinishContidtion(IGUIState guiState)
  23. {
  24. if (guiState.eventType == EventType.ExecuteCommand && guiState.commandName == m_CommandName)
  25. {
  26. guiState.UseEvent();
  27. return true;
  28. }
  29. return false;
  30. }
  31. protected override void OnFinish(IGUIState guiState)
  32. {
  33. if (onCommand != null)
  34. onCommand(guiState);
  35. }
  36. }
  37. }