Skip to content
This repository has been archived by the owner on Mar 11, 2024. It is now read-only.

Commit

Permalink
Fix video interaction volume buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
jitsew committed Dec 10, 2020
1 parent fae2ff7 commit b2fc0d8
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Assets/Scripts/InteractionPanels/VideoPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using UnityEngine.Audio;
using UnityEngine.UI;
using UnityEngine.Video;
using UnityEngine.XR;

public class VideoPanel : MonoBehaviour
{
Expand All @@ -24,6 +25,9 @@ public class VideoPanel : MonoBehaviour
public AudioMixer mixer;
public AudioMixerGroup mixerGroup;

private Controller controllerLeft;
private Controller controllerRight;

private bool volumeChanging;
private bool increaseButtonPressed;
private bool decreaseButtonPressed;
Expand Down Expand Up @@ -66,6 +70,12 @@ public void Init(string newTitle, string fullPath)
increaseVolumeButton.onClick.AddListener(IncreaseVolume);
}

if (XRSettings.enabled)
{
controllerLeft = GameObject.Find("LeftHand").GetComponentInChildren<Controller>();
controllerRight = GameObject.Find("RightHand").GetComponentInChildren<Controller>();
}

volumeSlider.onValueChanged.AddListener( _ => VolumeValueChanged());
mixer.SetFloat(Config.videoInteractionMixerChannelName, MathHelper.LinearToLogVolume(Config.VideoInteractionVolume));
volumeSlider.value = Config.VideoInteractionVolume;
Expand Down Expand Up @@ -147,6 +157,16 @@ public void VolumeValueChanged()

private void CheckButtonStates()
{
if (XRSettings.enabled
&& controllerLeft != null && controllerRight != null
&& !(controllerLeft.triggerDown || controllerRight.triggerDown) && (increaseButtonPressed || decreaseButtonPressed))
{
increaseButtonPressed = false;
decreaseButtonPressed = false;
increaseVolumeButton.enabled = false;
decreaseVolumeButton.enabled = false;
}

if (increaseButtonPressed)
{
//NOTE(Simon): When button is down, immediately change volume
Expand Down

0 comments on commit b2fc0d8

Please sign in to comment.