Made apple audio sources use OnManagedAwake
This commit is contained in:
@@ -3,12 +3,14 @@ using System;
|
||||
using System.Diagnostics.Tracing;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Audio;
|
||||
using Core;
|
||||
using Core.Lifecycle;
|
||||
|
||||
/// <summary>
|
||||
/// We automatically add the AudioSource component here so we can control it. Do not add it manually!
|
||||
/// </summary>
|
||||
[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<AudioSource>();
|
||||
}
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void OnEnable()
|
||||
protected override void OnManagedAwake()
|
||||
{
|
||||
audioSource = GetComponent<AudioSource>();
|
||||
AudioManager.Instance.RegisterNewAudioSource(this);
|
||||
@@ -54,6 +62,10 @@ public class AppleAudioSource : MonoBehaviour
|
||||
|
||||
public void Play(int requestedClipPriority)
|
||||
{
|
||||
if (audioSource == null)
|
||||
{
|
||||
audioSource = GetComponent<AudioSource>();
|
||||
}
|
||||
clipPriority = requestedClipPriority;
|
||||
if (audioSourceType == AudioSourceType.CriticalVO || audioSourceType == AudioSourceType.VO)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user