Skip to content

Commit 11499e3

Browse files
committed
fix(SoundSlider): Calculate total value
1 parent 38ba923 commit 11499e3

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Assets/JCSUnity/Scripts/UI/Slider/JCS_SoundSlider.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
*/
99
using UnityEngine;
1010
using UnityEngine.UI;
11-
using MyBox;
1211

1312
namespace JCSUnity
1413
{
@@ -22,7 +21,7 @@ public class JCS_SoundSlider : MonoBehaviour
2221

2322
private Slider mSlider = null;
2423

25-
[Separator("Initialize Variables (JCS_SoundSlider)")]
24+
[Header("** Initialize Variables (JCS_SoundSlider) **")]
2625

2726
[Tooltip("Sound type you would like the slider to control.")]
2827
[SerializeField]
@@ -42,7 +41,10 @@ private void Awake()
4241

4342
private void Update()
4443
{
45-
JCS_SoundSettings.instance.SetSoudnVolume(mSoundType, mSlider.value);
44+
float total = mSlider.maxValue - mSlider.minValue; // Find total.
45+
float val = mSlider.value / total; // Convert to 0 to 1 scale.
46+
47+
JCS_SoundSettings.instance.SetSoudnVolume(mSoundType, val);
4648
}
4749
}
4850
}

0 commit comments

Comments
 (0)