// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. using Microsoft.MixedReality.Toolkit.Input; using UnityEngine; using UnityEngine.Events; namespace Microsoft.MixedReality.Toolkit.UI { /// /// The base class for all receivers that attach to Interactables /// public abstract class ReceiverBase { /// /// Name of Event Receiver /// public string Name { get; protected set; } /// /// Defines whether Unity Events should be hidden in inspector for this type of EventReceiver /// public virtual bool HideUnityEvents => false; protected UnityEvent uEvent; /// /// Each Receiver has a base Event it raises, (in addition to others). /// public UnityEvent Event { get => uEvent; set => uEvent = value; } /// /// Targeted component for Event Receiver at runtime /// public MonoBehaviour Host { get; set; } /// /// Constructs an interaction receiver that will raise unity event when triggered. /// /// Unity event to invoke. Add more events in deriving class. /// Name of the unity event that will get invoked (visible in editor). protected ReceiverBase(UnityEvent ev, string name) { uEvent = ev; Name = name; } /// /// The state has changed /// public abstract void OnUpdate(InteractableStates state, Interactable source); /// /// A voice command was called /// public virtual void OnVoiceCommand(InteractableStates state, Interactable source, string command, int index = 0, int length = 1) { } /// /// A click event happened /// public virtual void OnClick(InteractableStates state, Interactable source, IMixedRealityPointer pointer = null) { } } }