Exemplo n.º 1
0
            private void EnsureStarted()
            {
                if (!_dllFixed)
                {
                    DLLSearchPathFixer.fix();
                    _dllFixed = true;
                }

                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;
                }
            }
            /// <summary>
            /// Call in a static constructor of an object depending on native code.
            ///
            /// It is required if that native DLL being accessed depends on other native DLLs alongside it.
            /// </summary>
            public static void fix()
            {
                // Amend DLL search path - see http://forum.unity3d.com/threads/dllnotfoundexception-when-depend-on-another-dll.31083/#post-1042180
                // for original inspiration for this code.

                var fixer = new DLLSearchPathFixer();
                fixer.ConditionallyAddRelativeDir("Plugins");
                fixer.ConditionallyAddRelativeDir(new List<String>() { "Plugins", IntPtr.Size == 4 ? "x86" : "x86_64" });
                fixer.ApplyChanges();
            }
            /// <summary>
            /// Call in a static constructor of an object depending on native code.
            ///
            /// It is required if that native DLL being accessed depends on other native DLLs alongside it.
            /// </summary>
            public static void fix()
            {
                // Amend DLL search path - see http://forum.unity3d.com/threads/dllnotfoundexception-when-depend-on-another-dll.31083/#post-1042180
                // for original inspiration for this code.

                var fixer = new DLLSearchPathFixer();

                fixer.ConditionallyAddRelativeDir("Plugins");
                fixer.ConditionallyAddRelativeDir(new List <String>()
                {
                    "Plugins", IntPtr.Size == 4 ? "x86" : "x86_64"
                });
                fixer.ApplyChanges();
            }
Exemplo n.º 4
0
 void Awake()
 {
     DLLSearchPathFixer.fix();
     //if an instance of this singleton does not exist, set the instance to this object and make it persist
     if (_instance == null)
     {
         _instance = this;
         DontDestroyOnLoad(this);
     }
     else
     {
         //if an instance of this singleton already exists, destroy this one
         if (_instance != this)
         {
             Destroy(this.gameObject);
         }
     }
 }
            // Use this for initialization
            void Start()
            {
                if (!_dllFixed)
                {
                    DLLSearchPathFixer.fix();
                    _dllFixed = true;
                }

                if (_clientObject == null)
                {
                    Debug.Log("[PVR-Unity] Starting");
                    _clientObject = new PVR.PVRClient();
                    if (!_clientObject.init())
                    {
                        Debug.LogError("[PVR-Unity] PVR Session init failed. Start PVR Server and restart the application.");
                        _errMsg = "Failed to init PVR Session.";
                        return;
                    }
                }
                if (_renderlib == null)
                {
                    if (!PVRRenderLib.IsRenderLibSupported())
                    {
                        _errMsg = "PVR render lib not support.";
                        return;
                    }
                    _renderlib = new PVRRenderLib();
                    if (!_renderlib.InitRenderLib())
                    {
                        Debug.LogError("[PVR-Unity] PVR RenderLib init failed.");
                        _errMsg = "Failed to init PVR render lib.";
                        return;
                    }
                }

                Screen.sleepTimeout = SleepTimeout.NeverSleep;
                pvrDisplayInfo info = new pvrDisplayInfo();

                if (_clientObject.getEyeDisplayInfo(pvrEyeType.pvrEye_Left, ref info) != pvrResult.pvr_success)
                {
                    Debug.LogError("[PVR-Unity] getHmdDisplayInfo failed.");
                    return;
                }
                Application.targetFrameRate = (Int32)info.refresh_rate;

                pvrEyeRenderInfo renderInfo = new pvrEyeRenderInfo();

                if (_clientObject.getEyeRenderInfo(pvrEyeType.pvrEye_Left, ref renderInfo) != pvrResult.pvr_success)
                {
                    Debug.LogError("[PVR-Unity] getEyeRenderInfo failed.");
                    return;
                }
                if (_clientObject.getFovTextureSize(pvrEyeType.pvrEye_Left, renderInfo.Fov, 1.0f, ref _renderTargetSize) != pvrResult.pvr_success)
                {
                    Debug.LogError("[PVR-Unity] getFovTextureSize failed.");
                    return;
                }
                _ready = true;
                UpdateRenderInfo();
                UpdateHmdPose();
                UpdateInputState();
            }
Exemplo n.º 6
0
 /// <summary>
 /// Static constructor that enhances the DLL search path to ensure dependent native dlls are found.
 /// </summary>
 static ClientKit()
 {
     DLLSearchPathFixer.fix();
 }
Exemplo n.º 7
0
 ////////////////////////////////////////////////////////////////////////////////////////////////
 /*--------------------------------------------------------------------------------------------*/
 public void Awake()
 {
     DLLSearchPathFixer.fix();
     Context = new ClientContext("com.osvr.LeapMotion.Test");
 }
Exemplo n.º 8
0
 void Awake()
 {
     DLLSearchPathFixer.fix();
     DontDestroyOnLoad(gameObject);
 }