Singularity/Library/PackageCache/com.unity.2d.path@5.0.2/Editor/IMGUI/GUIFramework/HoveredControlAction.cs

50 lines
1.5 KiB
C#
Raw Normal View History

2024-05-06 14:45:45 -04:00
using System;
using UnityEngine;
namespace UnityEditor.U2D.Path.GUIFramework
{
/// <summary>
/// Represents an action that is tied to a Control.
/// </summary>
public abstract class HoveredControlAction : GUIAction
{
private Control m_HoveredControl;
/// <summary>
/// The hovered control.
/// </summary>
public Control hoveredControl
{
get { return m_HoveredControl; }
}
/// <summary>
/// Initializes and returns an instance of HoverControlAction.
/// </summary>
/// <param name="control">The control to execcute an action for on hover.</param>
public HoveredControlAction(Control control)
{
m_HoveredControl = control;
}
/// <summary>
/// Determines whether the HoveredControlAction can trigger.
/// </summary>
/// <param name="guiState">The current state of the custom editor.</param>
/// <returns>Returns `true` if the HoveredControlAction can trigger. Otherwise, returns `false`.</returns>
protected override bool CanTrigger(IGUIState guiState)
{
return guiState.nearestControl == hoveredControl.ID;
}
/// <summary>
/// Calls the methods in its invocation list when triggered.
/// </summary>
/// <param name="guiState">The current state of the custom editor.</param>
protected override void OnTrigger(IGUIState guiState)
{
m_HoveredControl.SetActionID(ID);
}
}
}