private void RenderCam() { try { if (cam == null) { GameObject go = new GameObject("vBugPlaybackCamera"); go.transform.position = new Vector3(0, 0f, -1f); //far far away cam = go.AddComponent<Camera>(); cam.enabled = false; cam.clearFlags = CameraClearFlags.SolidColor; cam.backgroundColor = Color.black; cam.fieldOfView = 30f; cam.nearClipPlane = 0.25f; cam.farClipPlane = 2.5f; cam.useOcclusionCulling = false; cam.renderingPath = RenderingPath.VertexLit; cam.cullingMask = 1 << vBugEditorSettings.PlaybackRenderLayer; meshManager = go.AddComponent<WindowRenderer>(); Frankfort.VBug.Internal.GameObjectUtility.SetHideFlagsRecursively(go); } int newWdith = (int)mainRect.width; int newHeight = (int)mainRect.height; if (newWdith > 0 && newHeight > 0 && meshManager != null) { meshManager.SetObjectsToRender(mainRect, new GameObject[] { quadParent.gameObject });//, gimballParent.gameObject}); Camera current = Camera.current; Handles.DrawCamera(mainRect, cam, DrawCameraMode.Normal); Camera.SetupCurrent(current); } } catch (Exception e) { if (vBugEditorSettings.DebugMode) Debug.LogError(e.Message + e.StackTrace); } }
private void DestroySceneElements() { if (overlays != null) { foreach (BasePlaybackOverlay overlay in overlays) overlay.Dispose(); } if (cam != null) UnityEngine.Object.DestroyImmediate(cam.gameObject); if (quadParent != null) UnityEngine.Object.DestroyImmediate(quadParent.gameObject); overlays = null; cam = null; meshManager = null; quadParent = null; }