private void SetGameViewsEnabled(bool enabled) { Assembly asm = Assembly.GetAssembly(typeof(UnityEditor.EditorWindow)); Type type = asm.GetType("UnityEditor.GameView"); SceneViewUtilities.SetViewsEnabled(type, enabled); }
private void SetSceneViewsEnabled(bool enabled) { // It's costly to call through to SetViewsEnabled, so only call when the value has changed if (m_SceneViewsEnabled != enabled) { SceneViewUtilities.SetViewsEnabled(typeof(SceneView), enabled); m_SceneViewsEnabled = enabled; } }
void OnGUI() { if (beforeOnGUI != null) { beforeOnGUI(this); } SceneViewUtilities.ResetOnGUIState(); var rect = guiRect; rect.x = 0; rect.y = 0; rect.width = position.width; rect.height = position.height; guiRect = rect; var cameraRect = EditorGUIUtility.PointsToPixels(guiRect); PrepareCameraTargetTexture(cameraRect); m_Camera.cullingMask = m_CullingMask.HasValue ? m_CullingMask.Value.value : UnityEditor.Tools.visibleLayers; // Draw camera bool pushedGUIClip; DoDrawCamera(guiRect, out pushedGUIClip); if (m_ShowDeviceView) { SceneViewUtilities.DrawTexture(customPreviewCamera && customPreviewCamera.targetTexture ? customPreviewCamera.targetTexture : m_SceneTargetTexture, guiRect, pushedGUIClip); } GUILayout.BeginArea(guiRect); { if (GUILayout.Button("Toggle Device View", EditorStyles.toolbarButton)) { m_ShowDeviceView = !m_ShowDeviceView; } if (m_CustomPreviewCamera) { GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); m_UseCustomPreviewCamera = GUILayout.Toggle(m_UseCustomPreviewCamera, "Use Presentation Camera"); } GUILayout.EndHorizontal(); } } GUILayout.EndArea(); if (afterOnGUI != null) { afterOnGUI(this); } }
private void DoDrawCamera(Rect cameraRect, out bool pushedGUIClip) { pushedGUIClip = false; if (!m_Camera.gameObject.activeInHierarchy) { return; } //DrawGridParameters gridParam = grid.PrepareGridRender(camera, pivot, m_Rotation.target, m_Size.value, m_Ortho.target, AnnotationUtility.showGrid); SceneViewUtilities.DrawCamera(m_Camera, cameraRect, position, m_RenderMode, true, out pushedGUIClip); }
private void OnGUI() { if (onGUIDelegate != null) { onGUIDelegate(this); } var e = Event.current; if (e.type != EventType.ExecuteCommand && e.type != EventType.used) { SceneViewUtilities.ResetOnGUIState(); var guiRect = new Rect(0, 0, position.width, position.height); var cameraRect = EditorGUIUtility.PointsToPixels(guiRect); PrepareCameraTargetTexture(cameraRect); m_Camera.cullingMask = m_CullingMask.HasValue ? m_CullingMask.Value.value : UnityEditor.Tools.visibleLayers; // Draw camera bool pushedGUIClip; DoDrawCamera(guiRect, out pushedGUIClip); if (m_ShowDeviceView) { SceneViewUtilities.DrawTexture(customPreviewCamera && customPreviewCamera.targetTexture ? customPreviewCamera.targetTexture : m_SceneTargetTexture, guiRect, pushedGUIClip); } GUILayout.BeginArea(guiRect); { if (GUILayout.Button("Toggle Device View", EditorStyles.toolbarButton)) { m_ShowDeviceView = !m_ShowDeviceView; } if (m_CustomPreviewCamera) { GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); m_UseCustomPreviewCamera = GUILayout.Toggle(m_UseCustomPreviewCamera, "Use Presentation Camera"); } GUILayout.EndHorizontal(); } } GUILayout.EndArea(); } }
private void DoDrawCamera(Rect cameraRect, out bool pushedGUIClip) { pushedGUIClip = false; if (!m_Camera.gameObject.activeInHierarchy) { return; } if (!m_VRInitialized) { return; } SceneViewUtilities.DrawCamera(m_Camera, cameraRect, position, m_RenderMode, out pushedGUIClip); }
private void Update() { // If code is compiling, then we need to clean up the window resources before classes get re-initialized if (EditorApplication.isCompiling) { Close(); } // Force the window to repaint every tick, since we need live updating // This also allows scripts with [ExecuteInEditMode] to run SceneViewUtilities.SetSceneRepaintDirty(); // Re-enable the other scene views if there has been no activity from the HMD (allows editing in SceneView) if (Time.realtimeSinceStartup >= m_TimeSinceLastHMDChange + kHMDActivityTimeout) { SetSceneViewsEnabled(true); } }
private void OnGUI() { onGUIDelegate(this); SceneViewUtilities.ResetOnGUIState(); SetupCamera(); Rect guiRect = new Rect(0, 0, position.width, position.height); Rect cameraRect = EditorGUIUtility.PointsToPixels(guiRect); PrepareCameraTargetTexture(cameraRect); Handles.ClearCamera(cameraRect, m_Camera); m_Camera.cullingMask = Tools.visibleLayers; // Draw camera bool pushedGUIClip; DoDrawCamera(guiRect, out pushedGUIClip); SceneViewUtilities.BlitRT(m_SceneTargetTexture, guiRect, pushedGUIClip); }
private void SetSceneViewsEnabled(bool enabled) { SceneViewUtilities.SetViewsEnabled(typeof(SceneView), enabled); }