campfire/Assets/Scripts/OptionsVR.cs

47 lines
1.6 KiB
C#
Raw Permalink Normal View History

using Boo.Lang.Runtime.DynamicDispatching;
using UnityEngine;
using Valve.VR;
using Valve.VR.InteractionSystem;
public class OptionsVR : MonoBehaviour {
public Options Options;
public Transform Display;
public SteamVR_Action_Boolean MenuInput;
public bool MenuOpen = false;
[Header("Sliders")]
public LinearMapping MasterSlider;
public LinearMapping FireSlider;
public LinearMapping AmbientSlider;
public LinearMapping FootstepsSlider;
public LinearMapping DiarySlider;
public LinearMapping TeleportSlider;
private bool WasMenuOpen = false;
2020-06-12 21:28:40 +02:00
private Transform Anchor;
private void Start() {
Anchor = GameObject.FindGameObjectWithTag("Front Of Player Anchor").transform;
}
private void Update() {
if (MenuInput.stateDown) {
MenuOpen = !MenuOpen;
} else if (MenuOpen && (Display.position - Anchor.position).magnitude > 2) {
MenuOpen = false;
}
if (MenuOpen && !WasMenuOpen) {
transform.position = Anchor.position;
transform.rotation = Anchor.rotation;
}
Display.localScale = Vector3.Lerp(Display.localScale, MenuOpen ? new Vector3(1, 1, 1) : Vector3.zero, 10f * Time.deltaTime);
WasMenuOpen = MenuOpen;
Options.MasterVolume = MasterSlider.value;
Options.CampfireVolume = FireSlider.value;
Options.AmbientVolume = AmbientSlider.value;
Options.FootstepVolume = FootstepsSlider.value;
Options.DiaryVolume = DiarySlider.value;
Options.TeleportVolume = TeleportSlider.value;
}
}