Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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