No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

HoveredControlAction.cs 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System;
  2. using UnityEngine;
  3. namespace UnityEditor.U2D.Path.GUIFramework
  4. {
  5. /// <summary>
  6. /// Represents an action that is tied to a Control.
  7. /// </summary>
  8. public abstract class HoveredControlAction : GUIAction
  9. {
  10. private Control m_HoveredControl;
  11. /// <summary>
  12. /// The hovered control.
  13. /// </summary>
  14. public Control hoveredControl
  15. {
  16. get { return m_HoveredControl; }
  17. }
  18. /// <summary>
  19. /// Initializes and returns an instance of HoverControlAction.
  20. /// </summary>
  21. /// <param name="control">The control to execcute an action for on hover.</param>
  22. public HoveredControlAction(Control control)
  23. {
  24. m_HoveredControl = control;
  25. }
  26. /// <summary>
  27. /// Determines whether the HoveredControlAction can trigger.
  28. /// </summary>
  29. /// <param name="guiState">The current state of the custom editor.</param>
  30. /// <returns>Returns `true` if the HoveredControlAction can trigger. Otherwise, returns `false`.</returns>
  31. protected override bool CanTrigger(IGUIState guiState)
  32. {
  33. return guiState.nearestControl == hoveredControl.ID;
  34. }
  35. /// <summary>
  36. /// Calls the methods in its invocation list when triggered.
  37. /// </summary>
  38. /// <param name="guiState">The current state of the custom editor.</param>
  39. protected override void OnTrigger(IGUIState guiState)
  40. {
  41. m_HoveredControl.SetActionID(ID);
  42. }
  43. }
  44. }