-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSlider_VR_Interaction.cs
More file actions
37 lines (29 loc) · 1.08 KB
/
Slider_VR_Interaction.cs
File metadata and controls
37 lines (29 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using UnityEngine;
using UnityEngine.UI;
public class Slider_VR_Interaction : MonoBehaviour
{
public ExperimentState expState;
private Slider _slider;
public Transform sliderKnob;
public float[] knobRange = new float[2];
private float[] otherMinMax = new float[2];
private void Start()
{
_slider = GetComponent<Slider>();
}
private void Update()
{
//_slider.value = Remap(sliderKnob.localPosition.x);
otherMinMax[0] = _slider.minValue;
otherMinMax[1] = _slider.maxValue;
_slider.value = expState.Remap(sliderKnob.localPosition.x, knobRange, otherMinMax);
}
//public float Remap(float value)
//{
// return _slider.minValue + (value - knobRange[0]) * ((_slider.maxValue - _slider.minValue) / (knobRange[1] - knobRange[0]));
//}
//public float Remap(float value, float[] selfMinMax, float[] otherMinMax)
//{
// return otherMinMax[0] + (value - selfMinMax[0]) * ((otherMinMax[1] - otherMinMax[0]) / (selfMinMax[1] - selfMinMax[0]));
//}
}