Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using VRStandardAssets.Utils;
- namespace VRStandardAssets.Maze {
- public class ButtonRotateMaze : MonoBehaviour {
- [SerializeField]private VRInteractiveItem m_InteractiveItem; // Reference to the VRInteractiveItem
- [SerializeField]private VRInput m_VRInput; // Reference to the VRInput to detect button presses.
- public Transform VRHead;
- public CameraOrbit cameraOrbitScript; // CameraOrbit script
- public float rotationAmount = 200f; // How much to rotate the maze when a button is clicked
- private bool m_GazeOver; // Whether the user is currently looking at the bar.
- private void OnEnable() {
- m_VRInput.OnDown += HandleDown;
- m_VRInput.OnUp += HandleUp;
- m_InteractiveItem.OnOver += HandleOver;
- m_InteractiveItem.OnOut += HandleOut;
- }
- private void OnDisable() {
- m_VRInput.OnDown -= HandleDown;
- m_VRInput.OnUp -= HandleUp;
- m_InteractiveItem.OnOver -= HandleOver;
- m_InteractiveItem.OnOut -= HandleOut;
- }
- private void HandleDown() {
- // If the user is looking at the bar start the FillBar coroutine and store a reference to it.
- if (m_GazeOver) {
- if (VRHead.localRotation.eulerAngles.y < 150f) {
- RotateMaze(rotationAmount);
- }else {
- RotateMaze(-rotationAmount);
- }
- }
- }
- // Not using now
- private void HandleUp() {
- }
- private void HandleOver() {
- // The user is now looking at the bar.
- m_GazeOver = true;
- }
- private void HandleOut() {
- // The user is no longer looking at the bar.
- m_GazeOver = false;
- }
- // Use this for initialization
- void Start() {
- }
- // Update is called once per frame
- void Update() {
- }
- public void RotateMaze(float amount) {
- StartCoroutine(cameraOrbitScript.RotateCamera(amount));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment