Added extra sliders for audio (not audio logic not yet implemented) and got elevator outer buttons firing.
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.XR.Interaction.Toolkit;
|
||||
|
||||
public class ContinuoslocomotionConfigurator : MonoBehaviour
|
||||
{
|
||||
public Button turnOffButton;
|
||||
public Button turnOnButton;
|
||||
public ContinuousMoveProviderBase locomotion;
|
||||
|
||||
// Events for listeners
|
||||
public event Action<bool> OnLocomotionToggled; // true = enabled, false = disabled
|
||||
public event Action<float> OnSpeedChanged; // sends new speed
|
||||
|
||||
void Start()
|
||||
{
|
||||
turnOnButton.onClick.AddListener(enableLocomotion);
|
||||
turnOffButton.onClick.AddListener(disableLocomotion);
|
||||
turnOffButton.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public void UpdateSpeed(float speed)
|
||||
{
|
||||
locomotion.moveSpeed = speed;
|
||||
OnSpeedChanged?.Invoke(speed);
|
||||
}
|
||||
|
||||
private void enableLocomotion()
|
||||
{
|
||||
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.Click, gameObject);
|
||||
locomotion.enabled = true;
|
||||
turnOnButton.gameObject.SetActive(false);
|
||||
turnOffButton.gameObject.SetActive(true);
|
||||
OnLocomotionToggled?.Invoke(true);
|
||||
}
|
||||
|
||||
private void disableLocomotion()
|
||||
{
|
||||
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.Click, gameObject);
|
||||
locomotion.enabled = false;
|
||||
turnOnButton.gameObject.SetActive(true);
|
||||
turnOffButton.gameObject.SetActive(false);
|
||||
OnLocomotionToggled?.Invoke(false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user