sounds and fix junglism staircase
This commit is contained in:
1 parent
3171954d06
commit
1842f1e3da
15 files changed
+309
-953
No files matched your search
Executable
+39
@@ -0,0 +1,39 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
public enum Sound {
|
||||
MenuLow,
|
||||
MenuHigh,
|
||||
}
|
||||
|
||||
[RequireComponent(typeof(AudioSource))]
|
||||
public class Audio : MonoBehaviour {
|
||||
[SerializeField]
|
||||
Sound[] soundNames;
|
||||
|
||||
[SerializeField]
|
||||
AudioClip[] clips;
|
||||
|
||||
Dictionary<Sound, AudioClip> sounds = new();
|
||||
|
||||
AudioSource source;
|
||||
|
||||
void Start() {
|
||||
source = GetComponent<AudioSource>();
|
||||
|
||||
for (int i = 0; i < clips.Length; i++) {
|
||||
sounds.Add(soundNames[i], clips[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public void PlaySound(Sound s) {
|
||||
AudioClip clip;
|
||||
bool found = sounds.TryGetValue(s, out clip);
|
||||
if (clip) {
|
||||
source.clip = clip;
|
||||
source.Play(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user