forked from cgvr/DeltaVR
microphone stand has separate enter and exit proximity triggers
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class MicrophoneProximityTrigger : MonoBehaviour
|
||||
{
|
||||
public MicrophoneStand mic;
|
||||
public bool isEnter;
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (isEnter && other.gameObject.tag == "Player Head")
|
||||
{
|
||||
Debug.Log("collided with: " + other.gameObject.name);
|
||||
mic.OnPlayerApproach();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerExit(Collider other)
|
||||
{
|
||||
if (!isEnter && other.gameObject.tag == "Player Head")
|
||||
{
|
||||
Debug.Log("collider left with: " + other.gameObject.name);
|
||||
mic.OnPlayerLeave();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 802e078b61fa28949b02b767f4fe7226
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -26,36 +26,26 @@ public class MicrophoneStand : MonoBehaviour
|
||||
|
||||
}
|
||||
|
||||
void OnTriggerEnter(Collider other)
|
||||
public void OnPlayerApproach()
|
||||
{
|
||||
KbmController controller = other.GetComponent<KbmController>();
|
||||
Debug.Log("Mic stand collided with object " + other.gameObject.name);
|
||||
fmodWhisperBridge.OnWhisperSegmentUpdated += OnPlayerSpeechUpdated;
|
||||
fmodWhisperBridge.OnWhisperSegmentFinished += OnPlayerSpeechFinished;
|
||||
|
||||
if (controller != null || other.gameObject.tag == "Player Head")
|
||||
{
|
||||
fmodWhisperBridge.OnWhisperSegmentUpdated += OnPlayerSpeechUpdated;
|
||||
fmodWhisperBridge.OnWhisperSegmentFinished += OnPlayerSpeechFinished;
|
||||
|
||||
microphoneOffStatus.SetActive(false);
|
||||
microphoneOnStatus.SetActive(true);
|
||||
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.RadioButton, gameObject);
|
||||
fmodWhisperBridge.ActivateRecording();
|
||||
}
|
||||
microphoneOffStatus.SetActive(false);
|
||||
microphoneOnStatus.SetActive(true);
|
||||
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.RadioButton, gameObject);
|
||||
fmodWhisperBridge.ActivateRecording();
|
||||
}
|
||||
|
||||
private void OnTriggerExit(Collider other)
|
||||
public void OnPlayerLeave()
|
||||
{
|
||||
KbmController controller = other.GetComponent<KbmController>();
|
||||
if (controller != null | other.gameObject.tag == "Player Head")
|
||||
{
|
||||
fmodWhisperBridge.OnWhisperSegmentUpdated -= OnPlayerSpeechUpdated;
|
||||
fmodWhisperBridge.OnWhisperSegmentFinished -= OnPlayerSpeechFinished;
|
||||
fmodWhisperBridge.OnWhisperSegmentUpdated -= OnPlayerSpeechUpdated;
|
||||
fmodWhisperBridge.OnWhisperSegmentFinished -= OnPlayerSpeechFinished;
|
||||
|
||||
microphoneOffStatus.SetActive(true);
|
||||
microphoneOnStatus.SetActive(false);
|
||||
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.RadioButton, gameObject);
|
||||
fmodWhisperBridge.DeactivateRecording();
|
||||
}
|
||||
microphoneOffStatus.SetActive(true);
|
||||
microphoneOnStatus.SetActive(false);
|
||||
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.RadioButton, gameObject);
|
||||
fmodWhisperBridge.DeactivateRecording();
|
||||
}
|
||||
|
||||
private void OnPlayerSpeechUpdated(string text)
|
||||
|
||||
Reference in New Issue
Block a user