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