com.tunnelsnakes.audiosystem 1.1.2 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -43,7 +43,15 @@ public static class AudioManager {
|
|
|
43
43
|
|
|
44
44
|
private static Transform CreateContainer() {
|
|
45
45
|
GameObject containerObject = new GameObject("AudioContainer");
|
|
46
|
-
|
|
46
|
+
#if UNITY_EDITOR
|
|
47
|
+
if (!Application.isPlaying) {
|
|
48
|
+
containerObject.hideFlags = HideFlags.HideAndDontSave;
|
|
49
|
+
} else {
|
|
50
|
+
#endif
|
|
51
|
+
MonoBehaviour.DontDestroyOnLoad(containerObject);
|
|
52
|
+
#if UNITY_EDITOR
|
|
53
|
+
}
|
|
54
|
+
#endif
|
|
47
55
|
return containerObject.transform;
|
|
48
56
|
}
|
|
49
57
|
}
|
|
@@ -3,6 +3,7 @@ using System.Collections;
|
|
|
3
3
|
using System.Collections.Generic;
|
|
4
4
|
using UnityEngine;
|
|
5
5
|
|
|
6
|
+
[ExecuteAlways]
|
|
6
7
|
public class AudioPresenter : MonoBehaviour {
|
|
7
8
|
private AudioSource _audioSource;
|
|
8
9
|
private Vibration _vibration;
|
|
@@ -20,9 +21,12 @@ public class AudioPresenter : MonoBehaviour {
|
|
|
20
21
|
set { _audioSource.loop = value; }
|
|
21
22
|
}
|
|
22
23
|
|
|
24
|
+
[ExecuteAlways]
|
|
23
25
|
private void Awake() {
|
|
24
|
-
_audioSource
|
|
25
|
-
|
|
26
|
+
if (_audioSource == null) {
|
|
27
|
+
_audioSource = gameObject.AddComponent<AudioSource>();
|
|
28
|
+
_audioSource.playOnAwake = false;
|
|
29
|
+
}
|
|
26
30
|
}
|
|
27
31
|
|
|
28
32
|
public void SetClip(AudioClip clip) {
|
|
@@ -27,6 +27,17 @@ public class Sound : ScriptableObject {
|
|
|
27
27
|
return presenter;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
/// <summary>
|
|
31
|
+
/// Mostly for Unity events
|
|
32
|
+
/// </summary>
|
|
33
|
+
///
|
|
34
|
+
#if UNITY_EDITOR && ODIN_INSPECTOR
|
|
35
|
+
[Sirenix.OdinInspector.Button]
|
|
36
|
+
#endif
|
|
37
|
+
public void SimplePlay() {
|
|
38
|
+
Play();
|
|
39
|
+
}
|
|
40
|
+
|
|
30
41
|
protected AudioPresenter GetPresenter() {
|
|
31
42
|
AudioPresenter presenter = AudioManager.GetFreeAudioPresenter();
|
|
32
43
|
presenter.SetClip(_audioClip);
|
|
@@ -44,6 +44,14 @@ public class StackableSound : Sound {
|
|
|
44
44
|
return presenter;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
#if UNITY_EDITOR && ODIN_INSPECTOR
|
|
48
|
+
[Sirenix.OdinInspector.Button]
|
|
49
|
+
#endif
|
|
50
|
+
public void Reset() {
|
|
51
|
+
_lastSoundTime = 0f;
|
|
52
|
+
_currentExtraPitch = 0f;
|
|
53
|
+
}
|
|
54
|
+
|
|
47
55
|
private int GetCurrentStackSize() {
|
|
48
56
|
float timeDelta = _lastSoundTime - Time.time;
|
|
49
57
|
int size = (timeDelta < 0f ? -1 : 1) * Mathf.FloorToInt(Mathf.Abs(timeDelta / _timeStep));
|