Tanoda
SliderVolume.cs
Go to the documentation of this file.
1
/******************************************************************************
2
* Copyright (C) Ultraleap, Inc. 2011-2020. *
3
* *
4
* Use subject to the terms of the Apache License 2.0 available at *
5
* http://www.apache.org/licenses/LICENSE-2.0, or another agreement *
6
* between Ultraleap and you, your company or other organization. *
7
******************************************************************************/
8
9
using
UnityEngine
;
10
using
UnityEngine
.
UI
;
11
using
System.Collections;
12
13
namespace
Leap.Unity.InputModule
{
14
public
class
SliderVolume
: MonoBehaviour {
15
public
AudioSource
source
;
16
float
volume = 0f;
17
float
currentValue = -1f;
18
float
previousValue = -1f;
19
float
maxValue = 0f;
20
float
TimeLastSlid = 0f;
21
22
void
Start() {
23
maxValue = GetComponent<Slider>().maxValue;
24
}
25
26
void
Update() {
27
volume = Mathf.Lerp(volume, Mathf.Abs(currentValue - previousValue) * 40f, 0.4f);
28
previousValue = currentValue;
29
source
.volume = volume;
30
31
if
(Time.time - TimeLastSlid > 0.5f) {
32
source
.Stop();
33
}
else
if
(!
source
.isPlaying) {
34
source
.Play();
35
}
36
}
37
38
public
void
setSliderSoundVolume
(
float
sliderposition) {
39
currentValue = sliderposition / maxValue;
40
TimeLastSlid = Time.time;
41
}
42
}
43
}
Leap.Unity.InputModule.SliderVolume
Definition:
SliderVolume.cs:14
Leap.Unity.InputModule.SliderVolume.setSliderSoundVolume
void setSliderSoundVolume(float sliderposition)
Definition:
SliderVolume.cs:38
Leap.Unity.InputModule.SliderVolume.source
AudioSource source
Definition:
SliderVolume.cs:15
Leap.Unity.InputModule
Definition:
CompressibleUIEditor.cs:13
UnityEngine.UI
Definition:
HSVPicker/UtilityScripts/BoxSlider.cs:7
UnityEngine
Definition:
HSVPicker/UtilityScripts/BoxSlider.cs:7
Source
Assets
Plugins
LeapMotion
Legacy
UIInput
Scripts
Utilities
SliderVolume.cs
Generated by
1.9.3