1
0
forked from cgvr/DeltaVR

Settings are now loaded from and saved to the config.json file. Reworked the UI structure a bit (the script that manage the settings have to be active before the UI is opened to actually take effect at game startup). Fixed several UI bugs (slider deselection, UI labels blocking the sliders, etc).

This commit is contained in:
2026-02-03 21:47:16 +02:00
parent 415484c1f0
commit ba1f0c855d
8 changed files with 439 additions and 297 deletions

View File

@@ -9,6 +9,7 @@ public class ContinuoslocomotionConfigurator : MonoBehaviour
{
public Button turnOffButton;
public Button turnOnButton;
public MoveSliderDragHandler moveSpeedSlider;
public ContinuousMoveProviderBase locomotion;
// Events for listeners
@@ -19,13 +20,21 @@ public class ContinuoslocomotionConfigurator : MonoBehaviour
{
turnOnButton.onClick.AddListener(enableLocomotion);
turnOffButton.onClick.AddListener(disableLocomotion);
turnOffButton.gameObject.SetActive(false);
bool isContinuousLocomotion = ConfigManager.instance.GetIsContinuousLocomotion();
turnOffButton.gameObject.SetActive(isContinuousLocomotion);
locomotion.enabled = isContinuousLocomotion;
float continuousLocomotionSpeed = ConfigManager.instance.GetContinuousLocomotionSpeed();
moveSpeedSlider.SetHandleValue(continuousLocomotionSpeed);
locomotion.moveSpeed = continuousLocomotionSpeed;
}
public void UpdateSpeed(float speed)
{
locomotion.moveSpeed = speed;
OnSpeedChanged?.Invoke(speed);
WriteToConfig();
}
private void enableLocomotion()
@@ -35,6 +44,7 @@ public class ContinuoslocomotionConfigurator : MonoBehaviour
turnOnButton.gameObject.SetActive(false);
turnOffButton.gameObject.SetActive(true);
OnLocomotionToggled?.Invoke(true);
WriteToConfig();
}
private void disableLocomotion()
@@ -44,5 +54,12 @@ public class ContinuoslocomotionConfigurator : MonoBehaviour
turnOnButton.gameObject.SetActive(true);
turnOffButton.gameObject.SetActive(false);
OnLocomotionToggled?.Invoke(false);
WriteToConfig();
}
protected void WriteToConfig()
{
ConfigManager.instance.SetIsContinuousLocomotion(locomotion.enabled);
ConfigManager.instance.SetContinuousLocomotionSpeed(locomotion.moveSpeed);
}
}