Skip to content

Instantly share code, notes, and snippets.

@robochase6000
Last active March 12, 2017 03:15
Show Gist options
  • Save robochase6000/f2f31d5213f70f396cfb13120564b25e to your computer and use it in GitHub Desktop.
Save robochase6000/f2f31d5213f70f396cfb13120564b25e to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
public class HandHitbox : MonoBehaviour
{
void OnTriggerEnter(Collider collider)
{
Interactable interactable = collider.GetComponent<Interactable> ();
if (interactable != null) {
interactable.TouchedBy (this);
}
}
void OnTriggerExit(Collider collider)
{
Interactable interactable = collider.GetComponent<Interactable> ();
if (interactable != null) {
interactable.TouchedByComplete (this);
}
}
}
public class Interactable : MonoBehaviour {
virtual public void TouchedBy(HandHitbox hand)
{
}
virtual public void TouchedByComplete(HandHitbox hand)
{
}
}
public class PushButton : Interactable
{
public Animation Anim;
public TextMesh Label;
public event OnPushButtonPressed HandlePushButtonPressed;
override public void TouchedBy(HandHitbox hitbox)
{
base.TouchedBy (hitbox);
Anim.Play ("PushButtonDown");
if (HandlePushButtonPressed != null) {
HandlePushButtonPressed.Invoke (this);
}
}
override public void TouchedByComplete(HandHitbox hitbox)
{
base.TouchedByComplete (hitbox);
Anim.Play ("PushButtonUp");
}
}
public class ClearLogButton : PushButton
{
override public void TouchedBy(HandHitbox hitbox)
{
base.TouchedBy (hitbox);
WristLog.Instance.Clear ();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment