chore : bugfix with audio scripts and test in separate scene
This commit is contained in:
@@ -49,7 +49,7 @@ public class Audio_AudioManager : MonoBehaviour
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("AudioManager already exist! Destroying new ibnstance.");
|
||||
Debug.LogWarning("AudioManager already exist! Destroying new instance.");
|
||||
Destroy(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
[RequireComponent(typeof(Collider))]
|
||||
public class Audio_WwiseEventTrigger : MonoBehaviour
|
||||
{
|
||||
[System.Serializable]
|
||||
public class WwiseEventEntry
|
||||
{
|
||||
public string label = "Event";
|
||||
public AK.Wwise.Event wwiseEvent;
|
||||
public bool triggerOnEnter = true;
|
||||
public bool triggerOnExit = false;
|
||||
}
|
||||
|
||||
[Header("Wwise Events")]
|
||||
[SerializeField] private List<WwiseEventEntry> wwiseEvents = new List<WwiseEventEntry>();
|
||||
|
||||
[Header("Trigger Settings")]
|
||||
[SerializeField] private string playerTag = "Player";
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
GetComponent<Collider>().isTrigger = true;
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (!other.CompareTag(playerTag)) return;
|
||||
|
||||
foreach (var entry in wwiseEvents)
|
||||
{
|
||||
if (entry.triggerOnEnter && entry.wwiseEvent != null)
|
||||
entry.wwiseEvent.Post(other.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerExit(Collider other)
|
||||
{
|
||||
if (!other.CompareTag(playerTag)) return;
|
||||
|
||||
foreach (var entry in wwiseEvents)
|
||||
{
|
||||
if (entry.triggerOnExit && entry.wwiseEvent != null)
|
||||
entry.wwiseEvent.Post(other.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private void OnDrawGizmos()
|
||||
{
|
||||
BoxCollider box = GetComponent<BoxCollider>();
|
||||
if (box == null) return;
|
||||
|
||||
Gizmos.matrix = transform.localToWorldMatrix;
|
||||
Gizmos.color = new Color(1f, 0.5f, 0f, 0.25f);
|
||||
Gizmos.DrawCube(box.center, box.size);
|
||||
Gizmos.color = new Color(1f, 0.5f, 0f, 0.8f);
|
||||
Gizmos.DrawWireCube(box.center, box.size);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7c1cc6d5ab210fa4baa79dabb29253e3
|
||||
Reference in New Issue
Block a user