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(); } }
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 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(); } }