Assignment for RMIT Mixed Reality in 2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

45 lines
1.4 KiB

namespace VRTK.Examples
{
using UnityEngine;
using VRTK.Controllables;
using VRTK.Controllables.PhysicsBased;
using VRTK.Controllables.ArtificialBased;
public class ButtonReactor : MonoBehaviour
{
protected VRTK_PhysicsPusher buttonEvents;
protected VRTK_ArtificialPusher artbuttonEvents;
protected virtual void OnEnable()
{
buttonEvents = GetComponent<VRTK_PhysicsPusher>();
if (buttonEvents != null)
{
buttonEvents.MaxLimitReached += MaxLimitReached;
}
artbuttonEvents = GetComponent<VRTK_ArtificialPusher>();
if (artbuttonEvents != null)
{
artbuttonEvents.MaxLimitReached += MaxLimitReached;
}
}
protected virtual void OnDisable()
{
if (buttonEvents != null)
{
buttonEvents.MaxLimitReached -= MaxLimitReached;
}
if (artbuttonEvents != null)
{
artbuttonEvents.MaxLimitReached -= MaxLimitReached;
}
}
protected virtual void MaxLimitReached(object sender, ControllableEventArgs e)
{
VRTK_BaseControllable senderButton = sender as VRTK_BaseControllable;
VRTK_Logger.Info(senderButton.name + " was pushed");
}
}
}