using System.Collections; using System.Collections.Generic; using UnityEngine; using Vuforia; public class VRBcontroller : MonoBehaviour { public GameObject cube; public VirtualButtonBehaviour vb; public float y = 30; // Start is called before the first frame update void Start() { cube = GameObject.Find("Cube"); VirtualButtonBehaviour[] vbs = GetComponentsInChildren(); for(int i = 0; i < vbs.Length; i++) { vbs[i].RegisterOnButtonPressed(OnButtonPressed); vbs[i].RegisterOnButtonReleased(OnButtonReleased); } } public void OnButtonPressed(VirtualButtonBehaviour vb) { print(vb.name + "按鈕被按下 !"); cube.transform.Rotate(0,y,0); } public void OnButtonReleased(VirtualButtonBehaviour vb) { print (vb.name + "按鈕被放開 !"); } // Update is called once per frame void Update() { } }