private void EnableMicrophone() { bool enable = false; // Check to see if the user is within MaxDistance. float distance = Mathf.Abs( Vector3.Distance( ParentObject.transform.position, Camera.main.transform.position)); if (distance <= MaxDistance) { RaycastHit hitInfo; // Check to see if the user is facing the object. // We raycast in the direction of the user's gaze and check for collision with the Echo layer. enable = Physics.Raycast(Camera.main.transform.position, Camera.main.transform.forward, out hitInfo, 20f, LayerMask.GetMask("Echoer"), QueryTriggerInteraction.Collide); } if (enable) { // Resume the microphone stream. MicStream.MicResume(); } else { // Pause the microphone stream. MicStream.MicPause(); } }
// on device, deal with all the ways that we could suspend our program in as few lines as possible private void OnApplicationPause(bool pause) { if (pause) { CheckForErrorOnCall(MicStream.MicPause()); } else { CheckForErrorOnCall(MicStream.MicResume()); } }