using System;
using UnityEngine.Events;
using UnityEngine.XR.Interaction.Toolkit.Interactables;
using UnityEngine.XR.Interaction.Toolkit.Interactors;
namespace UnityEngine.XR.Interaction.Toolkit
{
///
/// Event data associated with an interaction event between an Interactor and Interactable.
///
///
/// This class is currently used to define the event args for the interaction events supported by the .
///
/// This abstract class can be used to define custom events that are based on an interaction between an
/// and an . If the custom event needs to be executed through the XR Interaction Toolkit interaction system
/// using , a custom extension of is be required.
///
///
/// The following example demonstrates the implementation of the .
///
///
///
///
///
///
///
///
///
///
public abstract partial class BaseInteractionEventArgs
{
///
/// The Interactor associated with the interaction event.
///
public IXRInteractor interactorObject { get; set; }
///
/// The Interactable associated with the interaction event.
///
public IXRInteractable interactableObject { get; set; }
}
#region Hover
///
/// that Unity invokes when an Interactor initiates hovering over an Interactable.
///
///
/// When an begins hovering an , this is invoked
/// by the . Use to implement a callback when
/// is invoked. Use to stop listening for the event invocation.
///
///
/// The following example adds a listener to the of an and implements custom callback functions
/// that will be called when the is invoked.
///
///
///
///
///
///
///
///
///
[Serializable]
public sealed class HoverEnterEvent : UnityEvent
{
}
///
/// Event data associated with the event when an Interactor initiates hovering over an Interactable.
///
///
/// When an begins hovering an , a is invoked
/// with as parameters. The provides the object,
/// the object, and the object associated with the hover event.
///
///
/// The following example adds a listener to the of an and implements customs callback functions
/// that will be called when the is invoked.
///
///
///
///
///
///
///
///
#region HoverEnterEventArgs
public class HoverEnterEventArgs : BaseInteractionEventArgs
{
///
/// The Interactor associated with the interaction event.
///
public new IXRHoverInteractor interactorObject
{
get => (IXRHoverInteractor)base.interactorObject;
set => base.interactorObject = value;
}
///
/// The Interactable associated with the interaction event.
///
public new IXRHoverInteractable interactableObject
{
get => (IXRHoverInteractable)base.interactableObject;
set => base.interactableObject = value;
}
///
/// The Interaction Manager associated with the interaction event.
///
public XRInteractionManager manager { get; set; }
}
#endregion
///
/// that Unity invokes when an Interactor ends hovering over an Interactable.
///
///
/// When an stops hovering an , this is invoked
/// by the . Use to implement a callback when
/// is invoked. Use to stop listening for the event invocation.
///
///
/// The following example adds a listener to the of an and implements custom callback functions
/// that will be called when the is invoked.
///
///
///
///
///
///
///
///
///
[Serializable]
public sealed class HoverExitEvent : UnityEvent
{
}
///
/// Event data associated with the event when an Interactor ends hovering over an Interactable.
///
///
/// When an ends hovering an , a is invoked
/// with as parameters. The provides the object,
/// the object, and the object associated with the hover event. It also provides
/// the boolean which will be if the or the
/// is unregistered with the , disabled, or destroyed during the hover. Additionally, will be
/// if either or is called manually.
///
///
/// The following example adds a listener to the of an and implements customs callback functions
/// that will be called when the is invoked. The are utilized in the
/// `XRInteractionEventsSample.OnInteractorHoverExit` callback to return early if the hover event was canceled.
///
///
///
///
///
///
///
///
public class HoverExitEventArgs : BaseInteractionEventArgs
{
///
/// The Interactor associated with the interaction event.
///
public new IXRHoverInteractor interactorObject
{
get => (IXRHoverInteractor)base.interactorObject;
set => base.interactorObject = value;
}
///
/// The Interactable associated with the interaction event.
///
public new IXRHoverInteractable interactableObject
{
get => (IXRHoverInteractable)base.interactableObject;
set => base.interactableObject = value;
}
///
/// The Interaction Manager associated with the interaction event.
///
public XRInteractionManager manager { get; set; }
///
/// Whether the hover was ended due to being canceled, such as from
/// either the Interactor or Interactable being unregistered due to being
/// disabled or destroyed.
///
public bool isCanceled { get; set; }
}
#endregion
#region Select
///
/// that Unity invokes when an Interactor initiates selecting an Interactable.
///
///
/// When an begins selecting an , this is invoked
/// by the . Use to implement a callback when
/// is invoked. Use to stop listening for the event invocation.
///
///
/// The following example adds a listener to the of an and implements custom callback functions
/// that will be called when the is invoked.
///
///
///
///
///
///
///
///
///
[Serializable]
public sealed class SelectEnterEvent : UnityEvent
{
}
///
/// Event data associated with the event when an Interactor initiates selecting an Interactable.
///
///
/// When an begins selecting an , a is invoked
/// with as parameters. The parameter provides the object,
/// the object, and the object associated with the select event.
///
///
/// The following example adds a listener to the of an and implements customs callback functions
/// that will be called when the is invoked.
///
///
///
///
///
///
///
///
public class SelectEnterEventArgs : BaseInteractionEventArgs
{
///
/// The Interactor associated with the interaction event.
///
public new IXRSelectInteractor interactorObject
{
get => (IXRSelectInteractor)base.interactorObject;
set => base.interactorObject = value;
}
///
/// The Interactable associated with the interaction event.
///
public new IXRSelectInteractable interactableObject
{
get => (IXRSelectInteractable)base.interactableObject;
set => base.interactableObject = value;
}
///
/// The Interaction Manager associated with the interaction event.
///
public XRInteractionManager manager { get; set; }
}
///
/// that Unity invokes when an Interactor ends selecting an Interactable.
///
///
/// When an stops selecting an , this is invoked
/// by the . Use to implement a callback when
/// is invoked. Use to stop listening for the event invocation.
///
///
/// The following example adds a listener to the of an and implements custom callback functions
/// that will be called when the is invoked.
///
///
///
///
///
///
///
///
///
[Serializable]
public sealed class SelectExitEvent : UnityEvent
{
}
///
/// Event data associated with the event when an Interactor ends selecting an Interactable.
///
///
/// When an ends selecting an , a is invoked
/// with as parameters. The provides the object,
/// the object, and the object associated with the selection. It also provides
/// the boolean which will be if the or the
/// is unregistered with the , disabled, or destroyed during selection. Additionally, will be
/// if either or
/// are called manually.
///
///
/// The following example adds a listener to the of an and implements customs callback functions
/// that will be called when the is invoked. The are utilized in the
/// `XRInteractionEventsSample.OnInteractorSelectExit` callback to return early if the selection event was canceled.
///
///
///
///
///
///
///
///
public class SelectExitEventArgs : BaseInteractionEventArgs
{
///
/// The Interactor associated with the interaction event.
///
public new IXRSelectInteractor interactorObject
{
get => (IXRSelectInteractor)base.interactorObject;
set => base.interactorObject = value;
}
///
/// The Interactable associated with the interaction event.
///
public new IXRSelectInteractable interactableObject
{
get => (IXRSelectInteractable)base.interactableObject;
set => base.interactableObject = value;
}
///
/// The Interaction Manager associated with the interaction event.
///
public XRInteractionManager manager { get; set; }
///
/// Whether the selection was ended due to being canceled, such as from
/// either the Interactor or Interactable being unregistered due to being
/// disabled or destroyed.
///
public bool isCanceled { get; set; }
}
#endregion
#region Focus
///
/// that Unity invokes when an Interaction group initiates focusing an Interactable.
///
///
/// The is a that is invoked when an that is a member of an
/// selects an .
///
/// When an interactable is focused, the maintains a reference to the focusing and the focused
/// . This focus state is maintained until the focusing selects a different , the
/// focusing selects 'nothing', or until the focused is selected by a different when the
/// is set to . If is set to
/// , the focus state will be maintained when another selects the .
///
/// The s are primarily called from the . If the selecting is not a member of a
/// , no will be invoked.
///
/// The can be used to implement custom callbacks when an is focused. Use
/// to bind a custom callback to the invocation and to stop listening for the event invocation.
///
///
/// The following example adds a listener to the of an and implements custom callback functions
/// that will be called when the is invoked.
///
///
///
///
///
///
///
///
///
[Serializable]
public sealed class FocusEnterEvent : UnityEvent
{
}
///
/// Event data associated with the event when an Interaction group gains focus of an Interactable.
///
///
/// When an that is a member of an selects an , a
/// is invoked with as parameters. The provides the object, the
/// object, the , and the object associated with the focus event.
///
///
/// The following example adds a listener to the of an and implements custom callback functions
/// that will be called when the is invoked.
///
///
///
///
///
///
///
///
public class FocusEnterEventArgs : BaseInteractionEventArgs
{
///
/// The interaction group associated with the interaction event.
///
public IXRInteractionGroup interactionGroup { get; set; }
///
/// The Interactable associated with the interaction event.
///
public new IXRFocusInteractable interactableObject
{
get => (IXRFocusInteractable)base.interactableObject;
set => base.interactableObject = value;
}
///
/// The Interaction Manager associated with the interaction event.
///
public XRInteractionManager manager { get; set; }
}
///
/// that Unity invokes when an Interaction group ends focusing an Interactable.
///
///
/// The is a that is invoked when an ends focusing an .
///
/// Focusing can be exited in a few different ways. If the focusing selects a different or the focusing
/// selects 'nothing', focusing will be ended. Alternatively, if the focused is selected by a different
/// when the is set to , focusing will be exited as well.
/// If is set to and another selects the
/// , focus will not be exited.
///
/// The s are primarily called from the .
///
/// The can be used to implement custom callbacks when focus is ended on an . Use
/// to bind a custom callback to the invocation and to stop listening for the event invocation.
///
///
/// The following example adds a listener to the of an and implements custom callback functions
/// that will be called when the is invoked.
///
///
///
///
///
///
///
///
///
[Serializable]
public sealed class FocusExitEvent : UnityEvent
{
}
///
/// Event data associated with the event when an Interaction group ends focusing an Interactable.
///
///
/// When an ends focusing an , a
/// is invoked with as parameters. The provides the object, the
/// object, the , and the object associated with the focus event.
/// It also provides the boolean which will be if the interactor is destroyed or the
/// is unregistered with the , disabled, or destroyed during focus.
///
///
/// The following example adds a listener to the of an and implements custom callback functions
/// that will be called when the is invoked.
///
///
///
///
///
///
///
///
public class FocusExitEventArgs : BaseInteractionEventArgs
{
///
/// The interaction group associated with the interaction event.
///
public IXRInteractionGroup interactionGroup { get; set; }
///
/// The Interactable associated with the interaction event.
///
public new IXRFocusInteractable interactableObject
{
get => (IXRFocusInteractable)base.interactableObject;
set => base.interactableObject = value;
}
///
/// The Interaction Manager associated with the interaction event.
///
public XRInteractionManager manager { get; set; }
///
/// Whether the focus was lost due to being canceled, such as from
/// either the Interaction group or Interactable being unregistered due to being
/// disabled or destroyed.
///
public bool isCanceled { get; set; }
}
#endregion
#region Activate
///
/// that Unity invokes when the selecting Interactor activates an Interactable.
///
///
/// Not to be confused with activating or deactivating a with .
/// This is a generic event when an wants to activate its selected ,
/// such as from a trigger pull on a controller.
///
///
/// The following example adds a listener to the of an and implements custom callback functions
/// that will be called when the is invoked.
///
///
///
///
///
///
///
///
///
[Serializable]
public sealed class ActivateEvent : UnityEvent
{
}
///
/// Event data associated with the event when the selecting Interactor activates an Interactable.
///
///
/// When an activates a selected , an
/// is invoked with as parameters. The provides the object and the
/// object associated with the activate event.
///
///
/// The following example adds a listener to the of an and implements custom callback functions
/// that will be called when the is invoked.
///
///
///
///
///
///
///
///
public class ActivateEventArgs : BaseInteractionEventArgs
{
///
/// The Interactor associated with the interaction event.
///
public new IXRActivateInteractor interactorObject
{
get => (IXRActivateInteractor)base.interactorObject;
set => base.interactorObject = value;
}
///
/// The Interactable associated with the interaction event.
///
public new IXRActivateInteractable interactableObject
{
get => (IXRActivateInteractable)base.interactableObject;
set => base.interactableObject = value;
}
}
///
/// that Unity invokes when the selecting Interactor deactivates an Interactable.
///
///
/// Not to be confused with activating or deactivating a with .
/// This is a generic event when an wants to deactivate its selected ,
/// such as from a trigger pull on a controller.
///
///
/// The following example adds a listener to the of an and implements custom callback functions
/// that will be called when the is invoked.
///
///
///
///
///
///
///
///
///
[Serializable]
public sealed class DeactivateEvent : UnityEvent
{
}
///
/// Event data associated with the event when the selecting Interactor deactivates an Interactable.
///
///
/// When an deactivates a selected and activated , a
/// is invoked with as parameters. The provides the object and the
/// object associated with the deactivate event.
///
///
/// The following example adds a listener to the of an and implements custom callback functions
/// that will be called when the is invoked.
///
///
///
///
///
///
///
///
public class DeactivateEventArgs : BaseInteractionEventArgs
{
///
/// The Interactor associated with the interaction event.
///
public new IXRActivateInteractor interactorObject
{
get => (IXRActivateInteractor)base.interactorObject;
set => base.interactorObject = value;
}
///
/// The Interactable associated with the interaction event.
///
public new IXRActivateInteractable interactableObject
{
get => (IXRActivateInteractable)base.interactableObject;
set => base.interactableObject = value;
}
}
#endregion
#region Registration
///
/// Event data associated with a registration event with an .
///
///
/// This class is currently used to define the event args for the registration events supported by the .
///
/// This abstract class can be used to define custom events that register some type of object with a custom extension of the .
///
///
/// The following example demonstrates the implementation of the .
///
///
///
///
///
///
///
///
public abstract class BaseRegistrationEventArgs
{
///
/// The Interaction Manager associated with the registration event.
///
public XRInteractionManager manager { get; set; }
}
///
/// Event data associated with the event when an is registered with an .
///
///
/// When an is registered with the , the
/// event and events are invoked
/// with as parameters.
///
/// provides the registering and the
/// associated with the registration event. Additionally, provides an optional
/// in the case that there is a containing or nested interaction group. If not set, will be .
///
///
/// The following example subscribes to the event and implements custom callback functions
/// that will be called when the is invoked. Enabling the "Example Interaction Group"
/// game object will trigger the registered callback, while disabling it will trigger the unregistered callback.
///
///
///
///
///
public class InteractionGroupRegisteredEventArgs : BaseRegistrationEventArgs
{
///
/// The Interaction Group that was registered.
///
public IXRInteractionGroup interactionGroupObject { get; set; }
///
/// The Interaction Group that contains the registered Group. Will be if there is no containing Group.
///
public IXRInteractionGroup containingGroupObject { get; set; }
}
///
/// Event data associated with the event when an Interactor is registered with an .
///
///
/// When an is registered with the , the
/// event and events are invoked
/// with as parameters.
///
/// provides the registering and the
/// associated with the registration event. Additionally, provides an optional
/// if the is part of an . If not set, will be .
///
///
/// The following example subscribes to the event and implements custom callback functions
/// that will be called when the is invoked. Enabling the "Example Interactor"
/// game object will trigger the registered callback, while disabling it will trigger the unregistered callback.
///
///
///
///
///
#region InteractorRegistrationEvent
public partial class InteractorRegisteredEventArgs : BaseRegistrationEventArgs
{
///
/// The Interactor that was registered.
///
public IXRInteractor interactorObject { get; set; }
///
/// The Interaction Group that contains the registered Interactor. Will be if there is no containing Group.
///
public IXRInteractionGroup containingGroupObject { get; set; }
}
#endregion
///
/// Event data associated with the event when an Interactable is registered with an .
///
///
/// When an is registered with the , the
/// event and events are invoked
/// with as parameters.
///
/// provides the registering and the
/// associated with the registration event.
///
///
/// The following example subscribes to the event and implements custom callback functions
/// that will be called when the is invoked. Enabling the "Example Interactable"
/// game object will trigger the registered callback, while disabling it will trigger the unregistered callback.
///
///
///
///
///
public partial class InteractableRegisteredEventArgs : BaseRegistrationEventArgs
{
///
/// The Interactable that was registered.
///
public IXRInteractable interactableObject { get; set; }
}
///
/// Event data associated with the event when an Interaction Group is unregistered from an .
///
///
/// When an is unregistered with the , the
/// event and events are invoked
/// with as parameters.
///
/// provides the unregistering and the
/// associated with the unregistration event.
///
///
/// The following example subscribes to the event and implements custom callback functions
/// that will be called when the is invoked. Enabling the "Example Interaction Group"
/// game object will trigger the registered callback, while disabling it will trigger the unregistered callback.
///
///
///
///
///
public class InteractionGroupUnregisteredEventArgs : BaseRegistrationEventArgs
{
///
/// The Interaction Group that was unregistered.
///
public IXRInteractionGroup interactionGroupObject { get; set; }
}
///
/// Event data associated with the event when an Interactor is unregistered from an .
///
///
/// When an is unregistered with the , the
/// event and events are invoked
/// with as parameters.
///
/// provides the unregistering and the
/// associated with the unregistration event.
///
///
/// The following example subscribes to the event and implements custom callback functions
/// that will be called when the is invoked. Enabling the "Example Interactor"
/// game object will trigger the registered callback, while disabling it will trigger the unregistered callback.
///
///
///
///
///
public partial class InteractorUnregisteredEventArgs : BaseRegistrationEventArgs
{
///
/// The Interactor that was unregistered.
///
public IXRInteractor interactorObject { get; set; }
}
///
/// Event data associated with the event when an Interactable is unregistered from an .
///
///
/// When an is unregistered with the , the
/// event and events are invoked
/// with as parameters.
///
/// provides the unregistering and the
/// associated with the unregistration event.
///
///
/// The following example subscribes to the event and implements custom callback functions
/// that will be called when the is invoked. Enabling the "Example Interactable"
/// game object will trigger the registered callback, while disabling it will trigger the unregistered callback.
///
///
///
///
///
public partial class InteractableUnregisteredEventArgs : BaseRegistrationEventArgs
{
///
/// The Interactable that was unregistered.
///
public IXRInteractable interactableObject { get; set; }
}
#endregion
}