private void Update() { // Find the UnityBroadcastController if (m_BroadcastController == null) { UnityEngine.Object[] arr = GameObject.FindObjectsOfType(typeof(UnityBroadcastController)); if (arr != null && arr.Length > 0) { m_BroadcastController = arr[0] as UnityBroadcastController; m_Api = m_BroadcastController.UnityBroadcastApi; m_AudioQueue = m_BroadcastController.PassthroughAudioQueue; m_SampleRate = AudioSettings.outputSampleRate; m_UsingPassthroughAudio = m_BroadcastController.AudioCaptureMethod == BroadcastController.GameAudioCaptureMethod.Passthrough; // We don't need to receive samples if the system isn't configured for passthrough if (!m_UsingPassthroughAudio) { // NOTE: There is currently no way to reenable the capturer if the game changes the capture method at runtime but this should never be the case this.enabled = false; } } } }
void Start() { Application.runInBackground = true; DebugOverlay.CreateInstance(); m_BroadcastController = this.gameObject.GetComponent<UnityBroadcastController>(); m_BroadcastController.AuthTokenRequestComplete += this.HandleAuthTokenRequestComplete; m_BroadcastController.LoginAttemptComplete += this.HandleLoginAttemptComplete; m_BroadcastController.GameNameListReceived += this.HandleGameNameListReceived; m_BroadcastController.BroadcastStateChanged += this.HandleBroadcastStateChanged; m_BroadcastController.LoggedOut += this.HandleLoggedOut; m_BroadcastController.StreamInfoUpdated += this.HandleStreamInfoUpdated; m_BroadcastController.FrameSubmissionIssue += this.HandleFrameSubmissionIssue; m_BroadcastController.IngestListReceived += this.HandleIngestListReceived; if (!m_BroadcastController.IsPlatformSupported) { DebugOverlay.Instance.AddViewportText("Operating system does not support broadcasting: " + System.Environment.OSVersion.ToString(), -1); } }