Skip to content

Instantly share code, notes, and snippets.

@thestonefox
Created July 16, 2016 08:23
Show Gist options
  • Save thestonefox/02bb6a877ebe17572ae24f44bf939719 to your computer and use it in GitHub Desktop.
Save thestonefox/02bb6a877ebe17572ae24f44bf939719 to your computer and use it in GitHub Desktop.
A basic concept of how to implement a custom tip in VRTK
using UnityEngine;
using System.Collections;
using VRTK;
public class CustomTip : MonoBehaviour {
private VRTK_WorldPointer pointer;
private GameObject cubeCursor;
private GameObject capsuleCursor;
private MeshRenderer sphereCursor;
void Start()
{
pointer = transform.GetComponentInParent<VRTK_WorldPointer>();
pointer.DestinationMarkerEnter += Pointer_DestinationMarkerEnter;
pointer.DestinationMarkerExit += Pointer_DestinationMarkerExit;
cubeCursor = transform.FindChild("Cube").gameObject;
capsuleCursor = transform.FindChild("Capsule").gameObject;
sphereCursor = GetComponent<MeshRenderer>();
}
private void Pointer_DestinationMarkerExit(object sender, DestinationMarkerEventArgs e)
{
cubeCursor.SetActive(false);
capsuleCursor.SetActive(false);
sphereCursor.enabled = true;
}
private void Pointer_DestinationMarkerEnter(object sender, DestinationMarkerEventArgs e)
{
switch(e.target.tag)
{
case "Cube":
sphereCursor.enabled = false;
capsuleCursor.SetActive(false);
cubeCursor.SetActive(true);
break;
case "Capsule":
sphereCursor.enabled = false;
cubeCursor.SetActive(false);
capsuleCursor.SetActive(true);
break;
default:
cubeCursor.SetActive(false);
capsuleCursor.SetActive(false);
sphereCursor.enabled = true;
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment