campfire/Assets/Scripts/OptionsVR.cs

43 lines
1.5 KiB
C#
Raw 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 Transform Anchor;
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;
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;
}
}