40 lines
933 B
C#
40 lines
933 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Runtime.Remoting.Messaging;
|
|
using UnityEngine;
|
|
using UnityEngine.PlayerLoop;
|
|
using UnityEngine.XR.Content.Interaction;
|
|
|
|
public class AlarmTrigger : MonoBehaviour
|
|
{
|
|
public XRPushButton PushButton;
|
|
public AudioSource AlarmSequence;
|
|
public AudioSource VentilationSequence;
|
|
private bool hasAlarm = false;
|
|
|
|
void Start()
|
|
{
|
|
if (PushButton != null)
|
|
{
|
|
PushButton.onPress.AddListener(OnButtonPressed);
|
|
}
|
|
}
|
|
|
|
void OnButtonPressed()
|
|
{
|
|
Debug.Log("Alarm button Pressed!");
|
|
VentilationSequence.Stop();
|
|
AlarmSequence.Play();
|
|
hasAlarm = true;
|
|
}
|
|
void Update()
|
|
{
|
|
if(hasAlarm && !AlarmSequence.isPlaying) // If alarm state has ended.
|
|
{
|
|
VentilationSequence.Play(); // Return to normal.
|
|
hasAlarm = false;
|
|
}
|
|
}
|
|
|
|
}
|