update new config system

This commit is contained in:
xpeng
2022-11-05 01:32:17 +01:00
parent be88d76799
commit d3840cb36e
40 changed files with 10198 additions and 628 deletions
+3 -1
View File
@@ -3,7 +3,9 @@
"rootNamespace": "",
"references": [
"GUID:80de51a1f88203a4cb129a5922de311f",
"GUID:fe685ec1767f73d42b749ea8045bfe43"
"GUID:fe685ec1767f73d42b749ea8045bfe43",
"GUID:6055be8ebefd69e48b49212b09b47b2f",
"GUID:e9ef0e10f8c2b264e9705f57f028b9e8"
],
"includePlatforms": [],
"excludePlatforms": [],
@@ -1,5 +1,4 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using UnityEngine;
using UnityEngine.XR;
public class ControllerHapticManager : MonoBehaviour
@@ -10,9 +9,14 @@ public class ControllerHapticManager : MonoBehaviour
public float amplitude = 1f;
void Start()
{
ConfigManager.onConfigChanged += ApplyConfig;
ConfigManager.EnsureInitialization();
ApplyConfig();
var durationWidget = ConfigManager.GetConfigPanelWidget("HapticDuration");
var amplitudeWidget = ConfigManager.GetConfigPanelWidget("HapticAmplitude");
var durationSlider = durationWidget.GetComponent<Slider>();
var amplitudeSlider = amplitudeWidget.GetComponent<Slider>();
durationSlider.onValueChanged.AddListener( (float value) => { duration = value;});
amplitudeSlider.onValueChanged.AddListener( (float value) => { amplitude = value;});
durationSlider.onValueChanged?.Invoke(duration);
amplitudeSlider.onValueChanged?.Invoke(amplitude);
}
private void OnTriggerEnter(Collider other)
{
@@ -24,9 +28,4 @@ public class ControllerHapticManager : MonoBehaviour
device = InputDevices.GetDeviceAtXRNode(Hand);
device.StopHaptics();
}
void ApplyConfig()
{
duration = ConfigManager.config.HapticDuration;
amplitude = ConfigManager.config.HapticAmplitude;
}
}
+23 -13
View File
@@ -1,12 +1,12 @@
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class HandFollowManager : MonoBehaviour
{
public GameObject Target;
public Transform Center;
public Config.handStabilization Mode;
public CEnum.handStabilization Mode;
public float VelocityThreshold = 0.1f;
private Rigidbody TargetRigidbody;
private Vector3 previousPosition;
@@ -14,14 +14,24 @@ public class HandFollowManager : MonoBehaviour
private void Start()
{
TargetRigidbody = Target.GetComponent<Rigidbody>();
ConfigManager.onConfigChanged += ApplyConfig;
ConfigManager.EnsureInitialization();
ApplyConfig();
}
private void ApplyConfig()
{
VelocityThreshold = ConfigManager.config.HandStabilVelocity;
Mode = ConfigManager.config.HandStabilizationMode;
var modeWidget = ConfigManager.GetConfigPanelWidget("HandStabilization");
var threshWidget = ConfigManager.GetConfigPanelWidget("Threshold");
var modeDropdown = modeWidget.GetComponent<TMP_Dropdown>();
var threshSlider = threshWidget.GetComponent<Slider>();
modeDropdown.onValueChanged.AddListener((int value) => {
VelocityThreshold = ConfigManager.config.HandStabilVelocity;
Mode = (CEnum.handStabilization)value;
});
threshSlider.onValueChanged.AddListener((float value) => {
VelocityThreshold = value;
});
modeDropdown.onValueChanged?.Invoke(modeDropdown.value);
threshSlider.onValueChanged?.Invoke(threshSlider.value);
}
private void VelocityTracking()
@@ -42,10 +52,10 @@ public class HandFollowManager : MonoBehaviour
{
switch (Mode)
{
case Config.handStabilization.Velocity:
case CEnum.handStabilization.Velocity:
VelocityTracking();
break;
case Config.handStabilization.None:
case CEnum.handStabilization.None:
transform.position = Target.transform.position;
break;
}