public void Delete() { if (m_handle == Types.INVALID_HANDLE) { return; } try { UnityInterface.Lock(); HvrPlayerInterfaceAPI.Actor_Delete(m_handle); #if VERBOSE_LOGGING Debug.Log("Delete " + GetType().Name + " Handle:" + handle); #endif UnityInterface.SceneObjectsRemove(m_handle); } catch (Exception e) { Debug.LogError(e.Message); } finally { m_handle = Types.INVALID_HANDLE; UnityInterface.Unlock(); } }
public void Create() { m_handle = Types.INVALID_HANDLE; if (!HvrHelper.Support.IsApplicationStateSupported()) { return; } try { UnityInterface.Lock(); if (HvrPlayerInterface.Initialise()) { m_handle = HvrPlayerInterfaceAPI.Actor_Create(); #if VERBOSE_LOGGING Debug.Log("Create " + GetType().Name + " Handle:" + handle); #endif UnityInterface.SceneObjectsAdd(m_handle, GetType().Name + m_handle, GetType().FullName); } } catch (Exception e) { Debug.LogError(e.Message); } finally { UnityInterface.Unlock(); } }
public PlayerInterface() { m_graphicsDeviceType = SystemInfo.graphicsDeviceType; Create(); UnityInterface.SceneObjectsAdd(handle, GetType().Name + handle, GetType().FullName); }
public static void Update() { if (IsInitialized()) { HvrPlayerInterfaceAPI.Interface_Update(); UnityInterface.Update(); } }
private void Create() { if (!HvrHelper.Support.IsApplicationStateSupported()) { return; } try { UnityInterface.Lock(); if (HvrPlayerInterface.Initialise()) { m_handle = HvrPlayerInterfaceAPI.Viewport_Create(); #if VERBOSE_LOGGING Debug.Log("Create " + GetType().Name + " Handle:" + handle); #endif UnityInterface.SceneObjectsAdd(handle, GetType().Name + handle, GetType().FullName); #if UNITY_5_5_OR_NEWER // No C# macro for reversed depth configuration. The only reference is: https://docs.unity3d.com/Manual/SL-PlatformDifferences.html if (SystemInfo.graphicsDeviceType == GraphicsDeviceType.Direct3D11 || SystemInfo.graphicsDeviceType == GraphicsDeviceType.Direct3D12 || SystemInfo.graphicsDeviceType == GraphicsDeviceType.PlayStation4 || SystemInfo.graphicsDeviceType == GraphicsDeviceType.XboxOne || SystemInfo.graphicsDeviceType == GraphicsDeviceType.Metal) { SetReverseDepthEnabled(true); } else { SetReverseDepthEnabled(false); } #else SetReverseDepthEnabled(false); #endif SetColorSpace(QualitySettings.activeColorSpace); } } catch (Exception e) { Debug.LogError(e.Message); } finally { UnityInterface.Unlock(); } }
public void Create(string renderMethodType) { m_handle = Types.INVALID_HANDLE; if (!HvrHelper.Support.IsApplicationStateSupported()) { return; } try { UnityInterface.Lock(); if (HvrPlayerInterface.Initialise()) { if (string.IsNullOrEmpty(renderMethodType)) { renderMethodType = HvrPlayerInterface.RenderMethod_GetDefaultMethodType(); } else { if (!HvrPlayerInterface.RenderMethod_IsTypeSupported(renderMethodType)) { Debug.LogWarning("Rendermethod '" + renderMethodType + "' is not supported on this platform. Defaulting to to '" + HvrPlayerInterface.RenderMethod_GetDefaultMethodType() + "'"); renderMethodType = HvrPlayerInterface.RenderMethod_GetDefaultMethodType(); } } m_type = renderMethodType; m_handle = HvrPlayerInterfaceAPI.RenderMethod_Create(renderMethodType); #if VERBOSE_LOGGING Debug.Log("Create " + GetType().Name + " Handle:" + handle); #endif UnityInterface.SceneObjectsAdd(handle, GetType().Name + handle, GetType().FullName); } } catch (Exception e) { Debug.LogError(e.Message); } finally { UnityInterface.Unlock(); } }
public static bool Initialise() { if (!HvrHelper.Support.IsApplicationStateSupported()) { return(false); } try { UnityInterface.Lock(); if (!HvrPlayerInterfaceAPI.Interface_IsInitialised()) { m_connection_check_lastTime = 0.0f; Types.InterfaceInitialiseInfo info = new Types.InterfaceInitialiseInfo(); info.structSize = (uint)Marshal.SizeOf(typeof(Types.InterfaceInitialiseInfo));; info.appId = Application.productName; info.appVersion = Application.version; info.extensionPath = HvrHelper.GetExtensionsPath(Application.platform); info.threadPoolSize = -1; HvrPlayerInterfaceAPI.Interface_Initialise(ref info); #if VERBOSE_LOGGING HvrPlayerInterfaceAPI.Interface_SetLogLevel(HvrPlayerInterfaceAPI.INTERFACE_LOG_TYPE_DEBUG); #else HvrPlayerInterfaceAPI.Interface_SetLogLevel(HvrPlayerInterfaceAPI.INTERFACE_LOG_TYPE_ERROR); #endif HvrPlayerInterfaceAPI.Interface_SetLogCallback(UnityInterfaceAPI.LogBuffer_Add); } } catch (Exception e) { Debug.LogError(e.Message); } finally { UnityInterface.Unlock(); } bool initialized = HvrPlayerInterfaceAPI.Interface_IsInitialised(); return(initialized); }
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(); } }
public void Create(Types.AssetCreationInfo info) { m_handle = Types.INVALID_HANDLE; if (!HvrHelper.Support.IsApplicationStateSupported()) { return; } try { UnityInterface.Lock(); if (HvrPlayerInterface.Initialise()) { m_assetCreationInfo = info; m_assetCreationInfo.structSize = (uint)Marshal.SizeOf(typeof(Types.AssetCreationInfo)); GCHandle assetHandle = GCHandle.Alloc(this); IntPtr assetPtr = (IntPtr)assetHandle; m_assetCreationInfo.userData = assetPtr; // https://answers.unity.com/questions/1229036/callbacks-from-c-to-c-are-not-working-in-540f3.html?sort=votes // For both IL2CPP and Mono on an AOT platform (like iOS) it is not possible to marshal an instance method to a function pointer // that can be called from native code. Only static methods in C# code be called from native code like this. m_assetCreationInfo.onInitialized = Callbacks.OnAssetInitialised; m_assetCreationInfo.onRepresentationDataRecieved = Callbacks.OnAssetRepresentationDataReceived; m_assetCreationInfo.onSelectRepresentation = Callbacks.OnAssetSelectRepresentation; m_handle = HvrPlayerInterfaceAPI.Asset_CreateFromInfo(ref m_assetCreationInfo); if (m_assetCreationInfo.assetPath.StartsWith("tcp")) { m_assetType = AssetSource.RealTime; } else if (m_assetCreationInfo.assetPath.EndsWith("8imanifest")) { m_assetType = AssetSource.VOD; } else { m_assetType = AssetSource.Local; } #if VERBOSE_LOGGING Debug.Log("Create " + GetType().Name + " Handle:" + handle); #endif UnityInterface.SceneObjectsAdd(handle, GetType().Name + handle, GetType().FullName); } } catch (Exception e) { Debug.LogError(e.Message); } finally { UnityInterface.Unlock(); } }
private void Create() { #if UNITY_EDITOR // The GetUnityRenderDevice and graphicsDeviceType will be Null if the editor is in batch mode // TODO: Handle case where user may want the player to be built during batch mode? if (InternalEditorUtility.inBatchMode) { return; } #endif if (!HvrHelper.Support.IsApplicationStateSupported()) { return; } // TODO, correct this by exposing the get native id int rendererType = HvrPlayerInterfaceAPI.RENDERER_TYPE_NONE; switch (SystemInfo.graphicsDeviceType) { case GraphicsDeviceType.Direct3D11: rendererType = HvrPlayerInterfaceAPI.RENDERER_TYPE_DIRECT3D11; break; #if !UNITY_5_5_OR_NEWER case GraphicsDeviceType.OpenGL2: #endif case GraphicsDeviceType.OpenGLCore: case GraphicsDeviceType.OpenGLES2: case GraphicsDeviceType.OpenGLES3: rendererType = HvrPlayerInterfaceAPI.RENDERER_TYPE_OPENGL; break; case GraphicsDeviceType.Metal: rendererType = HvrPlayerInterfaceAPI.RENDERER_TYPE_METAL; break; default: break; } try { UnityInterface.Lock(); if (HvrPlayerInterface.Initialise()) { m_handle = HvrPlayerInterfaceAPI.Player_Create(rendererType, UnityInterfaceAPI.GetUnityRenderDevice()); #if VERBOSE_LOGGING Debug.Log("Create " + GetType().Name + " Handle:" + handle); #endif m_graphicsDeviceType = SystemInfo.graphicsDeviceType; } } catch (Exception e) { Debug.LogError(e.Message); } finally { UnityInterface.Unlock(); } }