-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGenericAudioLib.cs
57 lines (48 loc) · 1.49 KB
/
GenericAudioLib.cs
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
#if false // Hack into not compiling
using UnityEngine;
using System.Collections;
// Just a place for me to store audio code for ease of reusage. Ingore.
public class GenericAudioLib : MonoBehaviour{}
// Shooting guns, AI or otherwise.
public class AUDIOLIBShooting
{
[Header("Audio References")] // Audio Source & Clip
[SerializeField]
private AudioSource[] _ASources; // List of audio sources (Use 2 or more!)
[SerializeField]
private AudioClip[] _Aclips; // List of audio clips (Any amount)
[Header("Audio Settings")] // Audio Settings
[SerializeField]
private float _AudioVolume = 1f;
[SerializeField]
private bool _IsRandomPitchEnabled = false;
[SerializeField]
private float _AudioPitchMin;
[SerializeField]
private float _AudioPitchMax;
// Audio storage
private int _ActiveAudioSource = 0; // Current audio source cycle
void library()
{
// Audio Checks
if (_ActiveAudioSource + 1 > _ASources.Length) // Check if int is overboard
{
_ActiveAudioSource = 0;
}
if (_IsRandomPitchEnabled == true) // Randomize Pitch if Enabled
{
_ASources[_ActiveAudioSource].pitch = (Random.Range(_AudioPitchMin, _AudioPitchMax));
}
// Audio play
_ASources[_ActiveAudioSource].PlayOneShot(_Aclips[Random.Range (0, _Aclips.Length)], _AudioVolume);
_ActiveAudioSource++;
}
}
// TEMPLATE
public class AUDIOLIB
{
void library
{
}
}
#endif