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 OnLocomotionToggled; // true = enabled, false = disabled public event Action 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); } }