Firstborn/Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventData/BaseEventData.cs

67 lines
1.8 KiB
C#
Raw Normal View History

2023-03-28 13:24:16 -04:00
namespace UnityEngine.EventSystems
{
/// <summary>
/// A class that can be used for sending simple events via the event system.
/// </summary>
public abstract class AbstractEventData
{
protected bool m_Used;
/// <summary>
/// Reset the event.
/// </summary>
public virtual void Reset()
{
m_Used = false;
}
/// <summary>
/// Use the event.
/// </summary>
/// <remarks>
/// Internally sets a flag that can be checked via used to see if further processing should happen.
/// </remarks>
public virtual void Use()
{
m_Used = true;
}
/// <summary>
/// Is the event used?
/// </summary>
public virtual bool used
{
get { return m_Used; }
}
}
/// <summary>
/// A class that contains the base event data that is common to all event types in the new EventSystem.
/// </summary>
public class BaseEventData : AbstractEventData
{
private readonly EventSystem m_EventSystem;
public BaseEventData(EventSystem eventSystem)
{
m_EventSystem = eventSystem;
}
/// <summary>
/// >A reference to the BaseInputModule that sent this event.
/// </summary>
public BaseInputModule currentInputModule
{
get { return m_EventSystem.currentInputModule; }
}
/// <summary>
/// The object currently considered selected by the EventSystem.
/// </summary>
public GameObject selectedObject
{
get { return m_EventSystem.currentSelectedGameObject; }
set { m_EventSystem.SetSelectedGameObject(value, this); }
}
}
}