Nextrek
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
//----------------------------------------------
// NGUI: Next-Gen UI kit
// Copyright © 2011-2013 Tasharen Entertainment
//----------------------------------------------
using UnityEngine;
/// <summary>
/// Plays the specified sound.
/// </summary>
[AddComponentMenu("NGUI/Interaction/Play Sound")]
public class UIPlaySound : MonoBehaviour
{
public enum Trigger
{
OnClick,
OnMouseOver,
OnMouseOut,
OnPress,
OnRelease,
}
public AudioClip audioClip;
public Trigger trigger = Trigger.OnClick;
#if UNITY_3_5
public float volume = 1f;
public float pitch = 1f;
#else
[Range(0f, 1f)] public float volume = 1f;
[Range(0f, 2f)] public float pitch = 1f;
#endif
void OnHover (bool isOver)
{
if (enabled && ((isOver && trigger == Trigger.OnMouseOver) || (!isOver && trigger == Trigger.OnMouseOut)))
{
NGUITools.PlaySound(audioClip, volume, pitch);
}
}
void OnPress (bool isPressed)
{
if (enabled && ((isPressed && trigger == Trigger.OnPress) || (!isPressed && trigger == Trigger.OnRelease)))
{
NGUITools.PlaySound(audioClip, volume, pitch);
}
}
void OnClick ()
{
if (enabled && trigger == Trigger.OnClick)
{
NGUITools.PlaySound(audioClip, volume, pitch);
}
}
}
|
Revision |
Author |
Commited |
Message |
83
|
FMMortaroli
|
Tue 13 May, 2014 11:32:51 +0000 |
|