Beispiel #1
0
            private void EnsureStarted()
            {
                if (!_dllFixed)
                {
                    DLLSearchPathFixer.fix();
                    _dllFixed = true;
                }


                if (_serverAutoStarter == null && autoStartServer)
                {
#if UNITY_ANDROID
                    LoadOsvrAndroidLibraries();
#endif
                    _serverAutoStarter = new OSVR.ClientKit.ServerAutoStarter();
                }

                if (_contextObject == null)
                {
                    if (0 == AppID.Length)
                    {
                        Debug.LogError("[OSVR-Unity] ClientKit instance needs AppID set to a reverse-order DNS name! Using dummy name...");
                        AppID = "com.osvr.osvr-unity.dummy";
                    }
                    Debug.Log("[OSVR-Unity] Starting with app ID: " + AppID);
                    _contextObject = new OSVR.ClientKit.ClientContext(AppID, 0);
                }


                //check if the server is running
                if (!_contextObject.CheckStatus())
                {
                    if (!_osvrServerError)
                    {
                        _osvrServerError = true;
                        Debug.LogError("[OSVR-Unity] OSVR Server not detected. Start OSVR Server and restart the application.");
                    }
                }
                else if (_osvrServerError)
                {
                    Debug.Log("[OSVR-Unity] OSVR Server connection established. You can ignore previous errors about the server not being detected.");
                    _osvrServerError = false;
                }
            }
Beispiel #2
0
            void Stop()
            {
                // Only stop the main instance, since it is the only one that
                // ever actually starts-up.
                if (this == instance)
                {
                    if (null != _contextObject)
                    {
                        Debug.Log("[OSVR-Unity] Shutting down OSVR.");
                        _contextObject.Dispose();
                        _contextObject = null;
#if UNITY_STANDALONE_WIN || UNITY_ANDROID
                        if (_serverAutoStarter != null)
                        {
                            _serverAutoStarter.Dispose();
                            _serverAutoStarter = null;
                        }
#endif
                    }
                }
            }