Here the Code/Link for the Scripts & Book
SpinScript.cs
using UnityEngine; using System.Collections; public class SpinScript : MonoBehaviour { public float speed = 10f; void Update() { transform.Rotate(Vector3.up, speed * Time.deltaTime); } }
ControllerMenu.cs
namespace VRTK.Examples { using UnityEngine; public class ControllerMenu : MonoBehaviour { public GameObject menuObject; private GameObject clonedMenuObject; private bool menuInit = false; private bool menuActive = false; private void Start() { GetComponent<VRTK_ControllerEvents>().ButtonTwoPressed += new ControllerInteractionEventHandler(DoMenuOn); GetComponent<VRTK_ControllerEvents>().ButtonTwoReleased += new ControllerInteractionEventHandler(DoMenuOff); menuInit = false; menuActive = false; } private void InitMenu() { clonedMenuObject = Instantiate(menuObject, transform.position, Quaternion.identity) as GameObject; clonedMenuObject.SetActive(true); menuInit = true; } private void DoMenuOn(object sender, ControllerInteractionEventArgs e) { if (!menuInit) { InitMenu(); } if (clonedMenuObject != null) { clonedMenuObject.SetActive(true); menuActive = true; } } private void DoMenuOff(object sender, ControllerInteractionEventArgs e) { if (clonedMenuObject != null) { clonedMenuObject.SetActive(false); menuActive = false; } } private void Update() { if (clonedMenuObject != null && menuActive) { clonedMenuObject.transform.rotation = transform.rotation; clonedMenuObject.transform.position = transform.position; } } } }
Book to Read: Unity Virtual Reality Projects
I personally really like this book and it helped me a lot to get started
Here the links to the Country Amazon Stores (Affliate Links)