48 lines
1.5 KiB
C#
48 lines
1.5 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace Beyond {
|
|
public class SubtitleTrigger : MonoBehaviour
|
|
{
|
|
// Start is called before the first frame update
|
|
HUDSubtitle m_subitleObject;
|
|
public string m_subitleToShow = "Enter text";
|
|
BoxCollider m_collider;
|
|
public bool m_shouldTriggerMusic = true;
|
|
public int m_musicNum = -1;
|
|
void Awake()
|
|
{
|
|
m_subitleObject = FindObjectOfType<HUDSubtitle>();
|
|
if (m_subitleObject == null)
|
|
{
|
|
Debug.LogError("No HUDSubitle object found!");
|
|
Destroy(this);
|
|
}
|
|
m_collider = GetComponent<BoxCollider>();
|
|
m_collider.isTrigger = true;
|
|
}
|
|
|
|
private void OnTriggerEnter(Collider other)
|
|
{
|
|
if (other.tag != "Player")
|
|
return;
|
|
if (m_subitleObject.ShowSubitle(m_subitleToShow) && m_shouldTriggerMusic)
|
|
{
|
|
if (MusicManager.instance)
|
|
MusicManager.instance.PlayExploration(m_musicNum);
|
|
}
|
|
}
|
|
|
|
public void OnDrawGizmos()
|
|
{
|
|
if (m_collider == null)
|
|
m_collider = GetComponent<BoxCollider>();
|
|
if (m_collider == null)
|
|
return;
|
|
Gizmos.color = Color.yellow;
|
|
Gizmos.matrix = transform.localToWorldMatrix;
|
|
Gizmos.DrawWireCube(m_collider.center, m_collider.size);
|
|
}
|
|
}
|
|
} |