Restore Defaults button to restore the default settings.
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[Serializable]
|
||||
abstract public class AbstractValueController : MonoBehaviour
|
||||
{
|
||||
abstract public void RestoreFromConfig();
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dfd6e172b2a79944788029ce9d4220dd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -3,9 +3,10 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
//using UnityEngine.UIElements;
|
||||
using UnityEngine.XR.Interaction.Toolkit;
|
||||
|
||||
public class ContinuoslocomotionConfigurator : MonoBehaviour
|
||||
public class ContinuoslocomotionConfigurator : AbstractValueController
|
||||
{
|
||||
public Button turnOffButton;
|
||||
public Button turnOnButton;
|
||||
@@ -21,9 +22,16 @@ public class ContinuoslocomotionConfigurator : MonoBehaviour
|
||||
turnOnButton.onClick.AddListener(enableLocomotion);
|
||||
turnOffButton.onClick.AddListener(disableLocomotion);
|
||||
|
||||
RestoreFromConfig();
|
||||
}
|
||||
|
||||
override public void RestoreFromConfig()
|
||||
{
|
||||
bool isContinuousLocomotion = ConfigManager.instance.GetIsContinuousLocomotion();
|
||||
turnOffButton.gameObject.SetActive(isContinuousLocomotion);
|
||||
turnOnButton.gameObject.SetActive(!isContinuousLocomotion);
|
||||
locomotion.enabled = isContinuousLocomotion;
|
||||
OnLocomotionToggled?.Invoke(isContinuousLocomotion);
|
||||
|
||||
float continuousLocomotionSpeed = ConfigManager.instance.GetContinuousLocomotionSpeed();
|
||||
moveSpeedSlider.SetHandleValue(continuousLocomotionSpeed);
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
public class RegularButtonView : MonoBehaviour, IPointerEnterHandler, IPointerClickHandler
|
||||
{
|
||||
|
||||
public void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.Hover, this.gameObject);
|
||||
}
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.Click, this.gameObject);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9c648a319c5c6aa47b3ef152a10657bf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,20 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Unity.Burst;
|
||||
using UnityEngine;
|
||||
|
||||
public class RestoreDefaultsController : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
public List<AbstractValueController> valueControllers = new List<AbstractValueController>();
|
||||
|
||||
public void OnRestoreDefaults()
|
||||
{
|
||||
ConfigManager.instance.RestoreDefaultConfig();
|
||||
|
||||
foreach (AbstractValueController avc in valueControllers)
|
||||
{
|
||||
avc.RestoreFromConfig();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1ebe1a3f8ef35a041a8ef39da672dd49
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,6 +1,6 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class SliderToVCA : MonoBehaviour
|
||||
public class SliderToVCA : AbstractValueController
|
||||
{
|
||||
public enum VCATarget
|
||||
{
|
||||
@@ -20,12 +20,16 @@ public class SliderToVCA : MonoBehaviour
|
||||
slider.OnValueChanged += ApplyVolume;
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
RestoreFromConfig();
|
||||
}
|
||||
|
||||
override public void RestoreFromConfig()
|
||||
{
|
||||
float initialValue = GetInitialValue();
|
||||
slider.SetHandleValue(initialValue);
|
||||
}
|
||||
|
||||
|
||||
private float GetInitialValue()
|
||||
{
|
||||
switch (target)
|
||||
|
||||
Reference in New Issue
Block a user