260913
This commit is contained in:
1 parent
d3aff16344
commit
74bf542515
20 files changed
+1416
-166
No files matched your search
@@ -0,0 +1,42 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
|
||||
public class Sensitivity : MonoBehaviour
|
||||
{
|
||||
[Header("UI 參照")]
|
||||
[Tooltip("Slider")]
|
||||
public Slider targetSlider;
|
||||
|
||||
[Tooltip("Text (TMP)")]
|
||||
public TextMeshProUGUI valueDisplayText;
|
||||
|
||||
void Start()
|
||||
{
|
||||
if (targetSlider != null)
|
||||
{
|
||||
targetSlider.minValue = 0.1f;
|
||||
targetSlider.maxValue = 10.0f;
|
||||
targetSlider.wholeNumbers = false;
|
||||
|
||||
UpdateDisplayText(targetSlider.value);
|
||||
|
||||
targetSlider.onValueChanged.AddListener(OnSliderValueChanged);
|
||||
}
|
||||
}
|
||||
|
||||
void OnSliderValueChanged(float rawValue)
|
||||
{
|
||||
float steppedValue = Mathf.Round(rawValue * 10f) / 10f;
|
||||
|
||||
UpdateDisplayText(steppedValue);
|
||||
}
|
||||
|
||||
void UpdateDisplayText(float val)
|
||||
{
|
||||
if (valueDisplayText != null)
|
||||
{
|
||||
valueDisplayText.text = $"靈敏度 : {val:F1}";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user