123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- using ObjectScripts;
- using Status;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using Valve.VR;
- using Valve.VR.Extras;
- using Valve.VR.InteractionSystem;
- public class InputHandling : MonoBehaviour
- {
- public SteamVR_Action_Boolean TimeSpeedUp = SteamVR_Input.GetAction<SteamVR_Action_Boolean>("CMController", "TimeSpeedUp");
- public SteamVR_Action_Boolean TimeSpeedDown = SteamVR_Input.GetAction<SteamVR_Action_Boolean>("CMController", "TimeSpeedDown");
- public SteamVR_Action_Boolean LODUp = SteamVR_Input.GetAction<SteamVR_Action_Boolean>("CMController", "LODUp");
- public SteamVR_Action_Boolean LODDown = SteamVR_Input.GetAction<SteamVR_Action_Boolean>("CMController", "LODDown");
- public SteamVR_Action_Boolean PlayPause = SteamVR_Input.GetAction<SteamVR_Action_Boolean>("CMController", "PlayPause");
- public SteamVR_Action_Boolean TimeReverse = SteamVR_Input.GetAction<SteamVR_Action_Boolean>("CMController", "ReverseTime");
- [SerializeField]
- [Tooltip("Object holding the Manager Script")]
- GameObject ManagerObject;
- [SerializeField]
- [Tooltip("Object holding the Details Script")]
- GameObject DetailsObject;
- [SerializeField]
- [Tooltip("Assign Handheld Canvases like 0 = Play, 1 = Stop, 2 = VelocityText")]
- GameObject[] Buttons;
- private Interactable Interactable;
- private ManagerWithProzessor Manager;
- private DetailsLevel Details;
- private float lastState;
- // Start is called before the first frame update
- void Start()
- {
- Manager = ManagerObject.GetComponent<ManagerWithProzessor>();
- Interactable = GetComponent<Interactable>();
- Details = DetailsObject.GetComponent<DetailsLevel>();
- lastState = 0;
- }
- // Update is called once per frame
- void Update()
- {
- if (Interactable.attachedToHand)
- {
- // Lokales Are good!
- SteamVR_Input_Sources hand = Interactable.attachedToHand.handType;
- bool TSU = TimeSpeedUp.GetStateDown(hand);
- bool TSD = TimeSpeedDown.GetStateDown(hand);
- bool LU = LODUp.GetStateDown(hand);
- bool LD = LODDown.GetStateDown(hand);
- bool PP = PlayPause.GetStateDown(hand);
- bool TR = TimeReverse.GetStateDown(hand);
- //Change TimeWarp
- if (TSU)
- Manager.PlusPressed();
- if (TSD)
- Manager.MinusPressed();
- // Play/Pause Simulation
- if (PP)
- CyclePP();
- //Cycle LODs
- if (LU)
- Details.CycleStates(1);
- if (LD)
- Details.CycleStates(-1);
- //TimeReverse
- if (TR)
- Manager.ReverseTime();
- }
- // Update one Handheld UI
- float v = (Manager.forward ? 1 : -1) * Manager.GameVelocity;
- if (lastState - v != 0)
- {
- Buttons[2].GetComponent<UnityEngine.UI.Text>().text = "" + v;
- if (Manager.GameVelocity == 0)
- {
- Buttons[1].SetActive(true);
- Buttons[0].SetActive(false);
- }
- else
- {
- Buttons[1].SetActive(false);
- Buttons[0].SetActive(true);
- }
- lastState = v;
- }
- }
- private void CyclePP()
- {
- if (Manager.GameVelocity == 0)
- Manager.PlayPressed();
- else
- Manager.StopPressed();
- }
- public ISteamVR_Action_In_Source[] AvalibleButtons()
- {
- return new ISteamVR_Action_In_Source[] { TimeSpeedUp, TimeSpeedDown, LODUp, LODDown, PlayPause };
- }
- }
|