diff --git a/Assets/Prefabs/Characters/PulverCharacter.prefab b/Assets/Prefabs/Characters/PulverCharacter.prefab index 7ba89fdf..20c39b93 100644 --- a/Assets/Prefabs/Characters/PulverCharacter.prefab +++ b/Assets/Prefabs/Characters/PulverCharacter.prefab @@ -248,7 +248,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 2bd397a60643eed45b586961ae6e3453, type: 3} m_Name: m_EditorClassIdentifier: AppleHillsScripts::PulverAudioController + audioSource: {fileID: 887004370483616855} combineAudio: {fileID: 8300000, guid: 768a16f348fe1d94c9cc267dc7ecf3b5, type: 3} + itemManager: {fileID: 0} --- !u!82 &4467608046243604209 AudioSource: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Sound/AppleAudioSource.cs b/Assets/Scripts/Sound/AppleAudioSource.cs index fdf60637..94d67caf 100644 --- a/Assets/Scripts/Sound/AppleAudioSource.cs +++ b/Assets/Scripts/Sound/AppleAudioSource.cs @@ -3,12 +3,14 @@ using System; using System.Diagnostics.Tracing; using UnityEngine; using UnityEngine.Audio; +using Core; +using Core.Lifecycle; /// /// We automatically add the AudioSource component here so we can control it. Do not add it manually! /// [RequireComponent(typeof(AudioSource))] -public class AppleAudioSource : MonoBehaviour +public class AppleAudioSource : ManagedBehaviour { public enum AudioSourceType{CriticalVO,VO,Ambience,SFX,Music} public AudioSourceType audioSourceType; @@ -17,8 +19,14 @@ public class AppleAudioSource : MonoBehaviour [HideInInspector ] public int clipPriority; public int sourcePriority; + + protected override void Awake() + { + base.Awake(); + audioSource = GetComponent(); + } // Start is called once before the first execution of Update after the MonoBehaviour is created - void OnEnable() + protected override void OnManagedAwake() { audioSource = GetComponent(); AudioManager.Instance.RegisterNewAudioSource(this); @@ -54,6 +62,10 @@ public class AppleAudioSource : MonoBehaviour public void Play(int requestedClipPriority) { + if (audioSource == null) + { + audioSource = GetComponent(); + } clipPriority = requestedClipPriority; if (audioSourceType == AudioSourceType.CriticalVO || audioSourceType == AudioSourceType.VO) { diff --git a/Assets/Scripts/Sound/BushAudioController.cs b/Assets/Scripts/Sound/BushAudioController.cs index bfdb5db7..993422e8 100644 --- a/Assets/Scripts/Sound/BushAudioController.cs +++ b/Assets/Scripts/Sound/BushAudioController.cs @@ -4,8 +4,10 @@ using System; using System.Diagnostics.Tracing; using UnityEngine; using UnityEngine.Audio; +using Core; +using Core.Lifecycle; -public class BushAudioController : MonoBehaviour +public class BushAudioController : ManagedBehaviour { private IAudioEventSource _eventSource; public AppleAudioSource VOPlayer; @@ -20,7 +22,7 @@ public class BushAudioController : MonoBehaviour // Start is called once before the first execution of Update after the MonoBehaviour is created - void Start() + protected override void OnManagedAwake() { _eventSource = VOPlayer.audioSource.RequestEventHandlers(); _eventSource.AudioStopped += PlayBirdCounter; diff --git a/Assets/Scripts/Sound/PulverAudioController.cs b/Assets/Scripts/Sound/PulverAudioController.cs index acba2b8a..f5c62f13 100644 --- a/Assets/Scripts/Sound/PulverAudioController.cs +++ b/Assets/Scripts/Sound/PulverAudioController.cs @@ -1,18 +1,17 @@ using Core; +using Core.Lifecycle; using UnityEngine; using UnityEngine.Audio; -public class PulverAudioController : MonoBehaviour +public class PulverAudioController : ManagedBehaviour { - private AppleAudioSource audioSource; + public AppleAudioSource audioSource; public AudioResource combineAudio; private FollowerController followerController; public ItemManager itemManager; - // Start is called once before the first execution of Update after the MonoBehaviour is created - void Start() + protected override void OnManagedAwake() { - audioSource = GetComponent(); followerController = GetComponent(); followerController.PulverIsCombining.AddListener(PulverIsCombining);