Interhaptics SDK for Unity
1.6
Loading...
Searching...
No Matches
Interhaptics
sdk_unity
Interhaptics
Runtime
Samples
UI
SourceIntensitySlider.cs
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2023 Go Touch VR SAS. All rights reserved.
3
*
4
*/
5
6
using
Interhaptics.Internal
;
7
using
UnityEngine;
8
using
UnityEngine.UI;
// Required for UI components
9
10
namespace
Interhaptics.Samples
11
{
12
[RequireComponent(typeof(Slider))]
13
public
class
SourceIntensitySlider
: MonoBehaviour
14
{
15
public
HapticSource
[]
hapticSources
;
16
private
Slider slider;
17
18
private
void
Awake()
19
{
20
slider = GetComponent<Slider>();
21
if
(
hapticSources
[0] !=
null
)
22
{
23
slider.value =
hapticSources
[0].
SourceIntensity
;
24
slider.onValueChanged.AddListener(
HandleSliderValueChanged
);
25
}
26
else
27
{
28
Debug.Log(
"No HapticSource component found in the HapticSources array."
);
29
}
30
}
31
32
public
void
HandleSliderValueChanged
(
float
value)
33
{
34
// Update the source intensity for all Haptic Sources when the slider's value changes
35
foreach
(
HapticSource
hapticSource
in
hapticSources
)
36
{
37
if
(hapticSource !=
null
)
38
{
39
hapticSource.SourceIntensity = value;
40
hapticSource.
ApplySourceIntensity
();
41
}
42
}
43
}
44
}
45
}
Interhaptics.Internal.HapticSource
Definition
HapticSource.cs:18
Interhaptics.Internal.HapticSource.SourceIntensity
float SourceIntensity
Definition
HapticSource.cs:72
Interhaptics.Internal.HapticSource.ApplySourceIntensity
void ApplySourceIntensity()
Call this method to apply the source intensity.
Definition
HapticSource.cs:185
Interhaptics.Samples.SourceIntensitySlider
Definition
SourceIntensitySlider.cs:14
Interhaptics.Samples.SourceIntensitySlider.HandleSliderValueChanged
void HandleSliderValueChanged(float value)
Definition
SourceIntensitySlider.cs:32
Interhaptics.Samples.SourceIntensitySlider.hapticSources
HapticSource[] hapticSources
Definition
SourceIntensitySlider.cs:15
Interhaptics.Internal
Definition
HapticDeviceManager.cs:13
Interhaptics.Samples
Definition
AudioControlGUI.cs:10
Generated by
1.11.0