12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- using UnityEngine;
- using System.Collections;
- using Valve.VR;
- using UnityEngine.UI;
- using Valve.VR.InteractionSystem;
- // Class that handles controller input.
- // Attached to GameObject Input in the hierachy.
- public class VRInput : MonoBehaviour
- {
- public GameObject CurrentMode;
-
- public bool inMenu => InteractionManagement.Instance.Menu_Opened;
- public bool isLocked => InteractionManagement.Instance.Robot_Locked;
- public Vector2 touchValue;
-
- private void Awake()
- {
-
- }
- // Start is called before the first frame update. At the beginning user is in menu and robot is locked.
- void Start()
- {
- if(CurrentMode != null && !CurrentMode.activeSelf){
- CurrentMode.SetActive(true);
- }
- }
-
- // Update is called once per frame
- void Update()
- {
- }
-
- // update the velocity and angle according to the mode
- public Vector2 getTouchValue()
- {
- Vector2 signal = Vector2.zero;
- if(CurrentMode!=null){
- signal = CurrentMode.GetComponent<IMode>().Signal;
- }
- touchValue = signal;
- return signal;
-
- }
- // Change the Mode so that it can get its signal
- public void SetMode(GameObject mode){
- if( this.CurrentMode != mode){
- if(this.CurrentMode != null){
- this.CurrentMode.SetActive(false);
- }
- mode.SetActive(true);
- this.CurrentMode = mode;
- }
- }
- }
|