public void OnEnable() { if (isInitialized) { pluginInterop.CleanupCommandBuffers(); } OnUpdateFrameInfoNotify += PauseOnFrame; }
private bool Initialize() { try { if (null != pluginInterop) { pluginInterop.Dispose(); } UnityConfig.ConvertToRelativePath(unityConfig.VertexShaderPath); UnityConfig.ConvertToRelativePath(unityConfig.PixelShaderPath); UnityConfig.ConvertToRelativePath(unityConfig.AtlasVertexShaderPath); UnityConfig.ConvertToRelativePath(unityConfig.BBoxFrameTexturePath); UnityConfig.ConvertToRelativePath(unityConfig.BBoxClipTexturePath); pluginInterop = new SVFUnityPluginInterop(unityConfig); HCapSettingsInterop hcapSettings = new HCapSettingsInterop() { defaultMaxVertexCount = DefaultMaxVertexCount, defaultMaxIndexCount = DefaultMaxIndexCount, allocMemoryMinGb = MemorySettings.MinGbLimitHW, allocMemoryMaxGb = MemorySettings.MaxGbLimitHW }; #if ENABLE_NATIVE_LOGGING pluginInterop.EnableTracing(true, LogLevel.Message); #endif pluginInterop.CreateHCapObject(hcapSettings); pluginInterop.CleanupCommandBuffers(); //foreach (var cam in Camera.allCameras) //{ // CameraView camView = cameraViews.Find(cam, targetDevice, flipHandedness); // pluginInterop.SetCommandBufferOnCamera(cam, camView.cameraId); //} #if UNITY_5_5_OR_NEWER pluginInterop.SetZBufferInverted(true); pluginInterop.SetTextureLoadTimeout(textureLoadTimeout); AudioVolume = _audioVolume; #endif if (meshRenderer == null) { meshRenderer = GetComponent <MeshRenderer>(); } if (meshFilter == null) { meshFilter = GetComponent <MeshFilter>(); } if (HVCollider == null) { HVCollider = GetComponent <BoxCollider>(); } if (renderingMode == RenderingMode.SVFDraw) { meshRenderer.receiveShadows = false; meshRenderer.shadowCastingMode = ShadowCastingMode.Off; meshRenderer.lightProbeUsage = LightProbeUsage.Off; meshRenderer.reflectionProbeUsage = ReflectionProbeUsage.Off; meshRenderer.materials = new Material[0]; // Mesh verts don't have to make sense for rendering in this mode, just for culling meshFilter.mesh.vertices = new Vector3[8]; meshFilter.mesh.RecalculateBounds(); } else if (renderingMode == RenderingMode.UnityDraw) { meshRenderer.material = material; meshFilter.mesh.bounds = localSpaceBounds; pluginInterop.SetUseGPU(useGPU); pluginInterop.SetComputeNormals(computeNormals); } isInitialized = true; } catch (Exception ex) { logger.LogException(ex); isInitialized = false; return(false); } return(true); }