private void Destruct() { if (m_actorInterface != null) { m_actorInterface.Delete(); m_actorInterface = null; } if (m_assetInterface != null) { m_assetInterface.Delete(); m_assetInterface = null; } if (m_renderMethodInterface != null) { m_renderMethodInterface.Delete(); m_renderMethodInterface = null; } HvrScene.Remove(this); }
private void Init() { #if UNITY_EDITOR // In the case that this component is a prefab, // don't allow interface objects to be created if (PrefabUtility.GetPrefabType(this) == PrefabType.Prefab) { return; } // There are issues with releasing unmanaged memory while running in batch mode for OSX and iOS // TODO: Remove this check if (UnityEditorInternal.InternalEditorUtility.inBatchMode) { return; } #endif m_actorInterface = new ActorInterface(); m_actorInterface.Create(); if (m_renderMethodInterface == null) { if (string.IsNullOrEmpty(m_renderMethodType)) { m_renderMethodType = HvrPlayerInterface.RenderMethod_GetDefaultMethodType(); } // Create this HvrActor's rendermethod // !! Always create the rendermethod before creating the asset as // !! there is a work around in SetRenderMethodInterface which requires // !! the asset to be recreated if the rendermethod changes CreateRenderMethod(m_renderMethodType); } if (m_assetInterface == null) { // Create the asset if (string.IsNullOrEmpty(data) == false) { CreateAsset(data, dataMode); } } if (m_assetInterface != null) { m_assetInterface.Seek(assetSeekTime); m_assetInterface.SetLooping(assetLoop); // Only allow assets to be played or seek when the application is playing if (Application.isPlaying) { if (assetPlay) { m_assetInterface.Play(); } } } #if UNITY_EDITOR // Handle case where HvrActor is duplicated within the Unity Editor // We need to ensure that the HvrActor has a unique material if (m_instanceID == 0) { m_instanceID = GetInstanceID(); } else if (m_instanceID != GetInstanceID() && GetInstanceID() < 0) { m_instanceID = GetInstanceID(); if (m_material != null) { Material mat = new Material(m_material.shader); mat.name = m_material.name; mat.CopyPropertiesFromMaterial(m_material); mat.shaderKeywords = m_material.shaderKeywords; m_material = mat; } } #endif m_renderMesh = new Mesh(); m_subroutineStack = new HvrActorShaderSubroutineStack(); HvrScene.Add(this); }