Exemplo n.º 1
0
        public static void Unlock_GL()
        {
            int eventID = UnityInterfaceAPI.QueueGLEvent(UnityInterfaceAPI.Unlock);

            GL.IssuePluginEvent(UnityInterfaceAPI.UnityRenderEventFunc(), eventID);
            GL.InvalidateState();
        }
        public void Delete()
        {
            if (handle == Types.INVALID_HANDLE)
            {
                return;
            }

            // TODO: Verify that the below actually works
            // The locking will not be correct, as the Player needs to be deleted on the render thread
            // and the locks need to be executed on the same thread

            try
            {
                UnityInterface.Lock_GL();

#if VERBOSE_LOGGING
                Debug.Log("Delete " + GetType().Name + " Handle:" + handle);
#endif

                int eventID_detach = UnityInterfaceAPI.QueueGLEventI(HvrPlayerInterfaceAPI.Player_Detach, handle);
                GL.IssuePluginEvent(UnityInterfaceAPI.UnityRenderEventFunc(), eventID_detach);

                int eventID_delete = UnityInterfaceAPI.QueueGLEventI(HvrPlayerInterfaceAPI.Player_Delete, handle);
                GL.IssuePluginEvent(UnityInterfaceAPI.UnityRenderEventFunc(), eventID_delete);

                int eventID_remove = UnityInterfaceAPI.QueueGLEventI(UnityInterfaceAPI.Scene_Objects_Remove, handle);
                GL.IssuePluginEvent(UnityInterfaceAPI.UnityRenderEventFunc(), eventID_remove);

                m_handle = Types.INVALID_HANDLE;
            }
            catch (Exception e)
            {
                Debug.LogError(e.Message);
            }
            finally
            {
                UnityInterface.Unlock_GL();
            }
        }