Essentielle Ordner, Prefabs, Skriptgerüst für die Audio Planung erstellt, sowie in dem SFX Manager den Skript von meinem anderen Projekt Derma Dread gezogen.
This commit is contained in:
30
Assets/Scripts/Audio/SFX Manager.cs
Normal file
30
Assets/Scripts/Audio/SFX Manager.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using UnityEngine;
|
||||
|
||||
// Written by Lilia Schwab
|
||||
public class SFXManager : MonoBehaviour
|
||||
{
|
||||
public static SFXManager instance;
|
||||
|
||||
[SerializeField] private AudioSource sFXObject;
|
||||
|
||||
private void Awake() {
|
||||
if (instance == null) {
|
||||
instance = this;
|
||||
}
|
||||
}
|
||||
|
||||
// Muss noch schauen, wie ich das f<>r das jeweilige Vieh seine seperaten Sounds einstelle und nicht universal
|
||||
public void PlaySFXClip(AudioClip clip, Transform spawnTransform, float volume) {
|
||||
AudioSource audioSource = Instantiate(sFXObject, spawnTransform.position, Quaternion.identity);
|
||||
|
||||
audioSource.clip = clip;
|
||||
|
||||
audioSource.volume = volume;
|
||||
|
||||
audioSource.Play();
|
||||
|
||||
float clipLength = audioSource.clip.length;
|
||||
|
||||
Destroy(audioSource, clipLength);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user