Пример #1
0
        public void StopRemotingConnection()
        {
            var xrManager = XRGeneralSettings.Instance?.Manager ?? null;

            if (xrManager != null)
            {
                xrManager.StopSubsystems();
                xrManager.DeinitializeLoader();
            }
            WindowsMRRemoting.Disconnect();
        }
Пример #2
0
        IEnumerator TryConnect()
        {
            WindowsMRRemoting.remoteMachineName = m_RemoteMachineName;
            WindowsMRRemoting.isAudioEnabled    = m_EnableAudio;
            WindowsMRRemoting.isVideoEnabled    = m_EnableVideo;
            WindowsMRRemoting.maxBitRateKbps    = m_MaxBitRateKbps;

            WindowsMRRemoting.Connect();

            yield return(new WaitForEndOfFrame());

            ConnectionState connectionState = ConnectionState.Disconnected;

            int connectionTryCount = 0;

            while (WindowsMRRemoting.TryGetConnectionState(out connectionState) && connectionTryCount < 30)
            {
                connectionTryCount++;
                if (connectionState == ConnectionState.Connecting)
                {
                    Debug.Log($"Still connecting to {WindowsMRRemoting.remoteMachineName}...");
                    yield return(new WaitForSeconds(1));

                    continue;
                }
                break;
            }

            switch (connectionState)
            {
            case ConnectionState.Connected:
                Debug.Log($"Successfully connected to {WindowsMRRemoting.remoteMachineName} after {connectionTryCount} seconds.");

                yield return(XRGeneralSettings.Instance.Manager.InitializeLoader());

                if (XRGeneralSettings.Instance.Manager.activeLoader != null)
                {
                    XRGeneralSettings.Instance.Manager.activeLoader.Start();
                }
                break;

            case ConnectionState.Disconnected:
                Debug.LogError($"Unable to connect to {WindowsMRRemoting.remoteMachineName} after {connectionTryCount} seconds");
                ConnectionFailureReason failureReason = ConnectionFailureReason.None;
                WindowsMRRemoting.TryGetConnectionFailureReason(out failureReason);
                Debug.LogError($"Connection Failure Reason {failureReason}");
                break;
            }
        }