internal static void InitPlaymodeLayout() { EditorApplicationLayout.m_GameView = WindowLayout.ShowAppropriateViewOnEnterExitPlaymode(true) as GameView; if ((Object) EditorApplicationLayout.m_GameView == (Object) null) return; if (EditorApplicationLayout.m_GameView.maximizeOnPlay) { DockArea parent = EditorApplicationLayout.m_GameView.m_Parent as DockArea; if ((Object) parent != (Object) null && !parent.actualView.m_Parent.window.maximized) EditorApplicationLayout.m_RootSplit = WindowLayout.MaximizePrepare(parent.actualView); } EditorApplicationLayout.m_GameView.m_Parent.SetAsStartView(); Toolbar.RepaintToolbar(); }
internal static void InitPlaymodeLayout() { m_GameView = WindowLayout.ShowAppropriateViewOnEnterExitPlaymode(true) as GameView; if (m_GameView != null) { if (m_GameView.maximizeOnPlay) { DockArea parent = m_GameView.m_Parent as DockArea; if ((parent != null) && !parent.actualView.m_Parent.window.maximized) { m_MaximizePending = WindowLayout.MaximizePrepare(parent.actualView); } } m_GameView.m_Parent.SetAsStartView(); Toolbar.RepaintToolbar(); } }
internal static void InitPlaymodeLayout() { EditorApplicationLayout.m_GameView = (WindowLayout.ShowAppropriateViewOnEnterExitPlaymode(true) as GameView); if (EditorApplicationLayout.m_GameView == null) { return; } if (EditorApplicationLayout.m_GameView.maximizeOnPlay) { DockArea dockArea = EditorApplicationLayout.m_GameView.m_Parent as DockArea; if (dockArea != null) { ContainerWindow window = dockArea.actualView.m_Parent.window; if (!window.maximized) { EditorApplicationLayout.m_RootSplit = WindowLayout.MaximizePrepare(dockArea.actualView); } } } EditorApplicationLayout.m_GameView.m_Parent.SetAsStartView(); Toolbar.RepaintToolbar(); }
internal static void RepaintSceneAndGameViews() { SceneView.RepaintAll(); GameView.RepaintAll(); }
private void MaterialListing() { ProceduralMaterial[] sortedMaterials = this.GetSortedMaterials(); foreach (ProceduralMaterial material in sortedMaterials) { if (material.isProcessing) { base.Repaint(); SceneView.RepaintAll(); GameView.RepaintAll(); break; } } int length = sortedMaterials.Length; float num3 = ((GUIView.current.position.width - 16f) - 18f) - 2f; if ((num3 * 2f) < (length * 60f)) { num3 -= 16f; } int num4 = Mathf.Max(1, Mathf.FloorToInt(num3 / 60f)); int num5 = Mathf.CeilToInt(((float)length) / ((float)num4)); Rect viewRect = new Rect(0f, 0f, num4 * 60f, num5 * 76f); Rect rect = GUILayoutUtility.GetRect(viewRect.width, Mathf.Clamp(viewRect.height, 76f, 152f) + 1f); Rect position = new Rect(rect.x + 1f, rect.y + 1f, rect.width - 2f, rect.height - 1f); GUI.Box(rect, GUIContent.none, this.m_SubstanceStyles.gridBackground); GUI.Box(position, GUIContent.none, this.m_SubstanceStyles.background); this.m_ListScroll = GUI.BeginScrollView(position, this.m_ListScroll, viewRect, false, false); if (this.m_EditorCache == null) { this.m_EditorCache = new EditorCache(EditorFeatures.PreviewGUI); } for (int i = 0; i < sortedMaterials.Length; i++) { ProceduralMaterial target = sortedMaterials[i]; if (target != null) { float x = (i % num4) * 60f; float y = (i / num4) * 76f; Rect rect5 = new Rect(x, y, 60f, 76f); bool on = target.name == this.m_SelectedMaterialInstanceName; Event current = Event.current; int controlID = GUIUtility.GetControlID(previewNoDragDropHash, FocusType.Passive, rect5); switch (current.GetTypeForControl(controlID)) { case EventType.Repaint: { Rect rect6 = rect5; rect6.y = rect5.yMax - 16f; rect6.height = 16f; this.m_SubstanceStyles.resultsGridLabel.Draw(rect6, EditorGUIUtility.TempContent(target.name), false, false, on, on); break; } case EventType.MouseDown: if ((current.button == 0) && rect5.Contains(current.mousePosition)) { if (current.clickCount == 1) { this.m_SelectedMaterialInstanceName = target.name; current.Use(); } else if (current.clickCount == 2) { AssetDatabase.OpenAsset(target); GUIUtility.ExitGUI(); current.Use(); } } break; } rect5.height -= 16f; this.m_EditorCache[target].OnPreviewGUI(rect5, this.m_SubstanceStyles.background); } } GUI.EndScrollView(); }
public override void OnInspectorGUI() { base.serializedObject.Update(); Camera camera = (Camera)base.target; this.m_ShowBGColorOptions.target = (!this.m_ClearFlags.hasMultipleDifferentValues && (camera.clearFlags == CameraClearFlags.Color || camera.clearFlags == CameraClearFlags.Skybox)); this.m_ShowOrthoOptions.target = (!this.m_Orthographic.hasMultipleDifferentValues && camera.orthographic); this.m_ShowTargetEyeOption.target = (this.m_TargetEye.intValue != 3 || PlayerSettings.virtualRealitySupported); EditorGUILayout.PropertyField(this.m_ClearFlags, new GUILayoutOption[0]); if (EditorGUILayout.BeginFadeGroup(this.m_ShowBGColorOptions.faded)) { EditorGUILayout.PropertyField(this.m_BackgroundColor, new GUIContent("Background", "Camera clears the screen to this color before rendering."), new GUILayoutOption[0]); } EditorGUILayout.EndFadeGroup(); EditorGUILayout.PropertyField(this.m_CullingMask, new GUILayoutOption[0]); EditorGUILayout.Space(); CameraEditor.ProjectionType projectionType = (!this.m_Orthographic.boolValue) ? CameraEditor.ProjectionType.Perspective : CameraEditor.ProjectionType.Orthographic; EditorGUI.BeginChangeCheck(); EditorGUI.showMixedValue = this.m_Orthographic.hasMultipleDifferentValues; projectionType = (CameraEditor.ProjectionType)EditorGUILayout.EnumPopup("Projection", projectionType, new GUILayoutOption[0]); EditorGUI.showMixedValue = false; if (EditorGUI.EndChangeCheck()) { this.m_Orthographic.boolValue = (projectionType == CameraEditor.ProjectionType.Orthographic); } if (!this.m_Orthographic.hasMultipleDifferentValues) { if (EditorGUILayout.BeginFadeGroup(this.m_ShowOrthoOptions.faded)) { EditorGUILayout.PropertyField(this.m_OrthographicSize, new GUIContent("Size"), new GUILayoutOption[0]); } EditorGUILayout.EndFadeGroup(); if (EditorGUILayout.BeginFadeGroup(1f - this.m_ShowOrthoOptions.faded)) { EditorGUILayout.Slider(this.m_FieldOfView, 1f, 179f, new GUIContent("Field of View"), new GUILayoutOption[0]); } EditorGUILayout.EndFadeGroup(); } EditorGUILayout.PropertiesField(EditorGUI.s_ClipingPlanesLabel, this.m_NearAndFarClippingPlanes, EditorGUI.s_NearAndFarLabels, 35f, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_NormalizedViewPortRect, this.m_ViewportLabel, new GUILayoutOption[0]); EditorGUILayout.Space(); EditorGUILayout.PropertyField(this.m_Depth, new GUILayoutOption[0]); EditorGUILayout.IntPopup(this.m_RenderingPath, CameraEditor.kCameraRenderPaths, CameraEditor.kCameraRenderPathValues, EditorGUIUtility.TempContent("Rendering Path"), new GUILayoutOption[0]); if (this.m_ShowOrthoOptions.target && this.wantDeferredRendering) { EditorGUILayout.HelpBox("Deferred rendering does not work with Orthographic camera, will use Forward.", MessageType.Warning, true); } EditorGUILayout.PropertyField(this.m_TargetTexture, new GUILayoutOption[0]); if (!this.m_TargetTexture.hasMultipleDifferentValues) { RenderTexture renderTexture = this.m_TargetTexture.objectReferenceValue as RenderTexture; if (renderTexture && renderTexture.antiAliasing > 1 && this.wantDeferredRendering) { EditorGUILayout.HelpBox("Manual MSAA target set with deferred rendering. This will lead to undefined behavior.", MessageType.Warning, true); } } EditorGUILayout.PropertyField(this.m_OcclusionCulling, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_HDR, EditorGUIUtility.TempContent("Allow HDR"), new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_AllowMSAA, new GUILayoutOption[0]); this.DisplayCameraWarnings(); if (PlayerSettings.virtualRealitySupported) { EditorGUILayout.PropertyField(this.m_StereoSeparation, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_StereoConvergence, new GUILayoutOption[0]); } if (this.ShouldShowTargetDisplayProperty()) { int intValue = this.m_TargetDisplay.intValue; EditorGUILayout.Space(); EditorGUILayout.IntPopup(this.m_TargetDisplay, DisplayUtility.GetDisplayNames(), DisplayUtility.GetDisplayIndices(), EditorGUIUtility.TempContent("Target Display"), new GUILayoutOption[0]); if (intValue != this.m_TargetDisplay.intValue) { GameView.RepaintAll(); } } if (EditorGUILayout.BeginFadeGroup(this.m_ShowTargetEyeOption.faded)) { EditorGUILayout.IntPopup(this.m_TargetEye, CameraEditor.kTargetEyes, CameraEditor.kTargetEyeValues, EditorGUIUtility.TempContent("Target Eye"), new GUILayoutOption[0]); } EditorGUILayout.EndFadeGroup(); this.DepthTextureModeGUI(); this.CommandBufferGUI(); base.serializedObject.ApplyModifiedProperties(); }
public static bool LoadWindowLayout(string path, bool newProjectLayoutWasCreated) { Rect position = default(Rect); UnityEngine.Object[] array = Resources.FindObjectsOfTypeAll(typeof(ContainerWindow)); UnityEngine.Object[] array2 = array; for (int i = 0; i < array2.Length; i++) { ContainerWindow containerWindow = (ContainerWindow)array2[i]; if (containerWindow.showMode == ShowMode.MainWindow) { position = containerWindow.position; } } try { ContainerWindow.SetFreezeDisplay(true); WindowLayout.CloseWindows(); UnityEngine.Object[] array3 = InternalEditorUtility.LoadSerializedFileAndForget(path); List <UnityEngine.Object> list = new List <UnityEngine.Object>(); int j = 0; while (j < array3.Length) { UnityEngine.Object @object = array3[j]; EditorWindow editorWindow = @object as EditorWindow; if (editorWindow != null) { if (!(editorWindow.m_Parent == null)) { goto IL_16F; } UnityEngine.Object.DestroyImmediate(editorWindow, true); UnityEngine.Debug.LogError(string.Concat(new object[] { "Removed unparented EditorWindow while reading window layout: window #", j, ", type=", @object.GetType().ToString(), ", instanceID=", @object.GetInstanceID() })); } else { DockArea dockArea = @object as DockArea; if (!(dockArea != null) || dockArea.m_Panes.Count != 0) { goto IL_16F; } dockArea.Close(null); UnityEngine.Debug.LogError(string.Concat(new object[] { "Removed empty DockArea while reading window layout: window #", j, ", instanceID=", @object.GetInstanceID() })); } IL_178: j++; continue; IL_16F: list.Add(@object); goto IL_178; } ContainerWindow containerWindow2 = null; ContainerWindow containerWindow3 = null; for (int k = 0; k < list.Count; k++) { ContainerWindow containerWindow4 = list[k] as ContainerWindow; if (containerWindow4 != null && containerWindow4.showMode == ShowMode.MainWindow) { containerWindow3 = containerWindow4; if ((double)position.width != 0.0) { containerWindow2 = containerWindow4; containerWindow2.position = position; } } } for (int l = 0; l < list.Count; l++) { UnityEngine.Object object2 = list[l]; if (object2 == null) { UnityEngine.Debug.LogError("Error while reading window layout: window #" + l + " is null"); throw new Exception(); } if (object2.GetType() == null) { UnityEngine.Debug.LogError(string.Concat(new object[] { "Error while reading window layout: window #", l, " type is null, instanceID=", object2.GetInstanceID() })); throw new Exception(); } if (newProjectLayoutWasCreated) { MethodInfo method = object2.GetType().GetMethod("OnNewProjectLayoutWasCreated", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { method.Invoke(object2, null); } } } if (containerWindow2) { containerWindow2.position = position; containerWindow2.OnResize(); } if (containerWindow3 == null) { UnityEngine.Debug.LogError("Error while reading window layout: no main window found"); throw new Exception(); } containerWindow3.Show(containerWindow3.showMode, true, true); for (int m = 0; m < list.Count; m++) { EditorWindow editorWindow2 = list[m] as EditorWindow; if (editorWindow2) { editorWindow2.minSize = editorWindow2.minSize; } ContainerWindow containerWindow5 = list[m] as ContainerWindow; if (containerWindow5 && containerWindow5 != containerWindow3) { containerWindow5.Show(containerWindow5.showMode, true, true); } } GameView gameView = WindowLayout.GetMaximizedWindow() as GameView; if (gameView != null && gameView.maximizeOnPlay) { WindowLayout.Unmaximize(gameView); } if (newProjectLayoutWasCreated) { if (UnityConnect.instance.online && UnityConnect.instance.loggedIn && UnityConnect.instance.shouldShowServicesWindow) { UnityConnectServiceCollection.instance.ShowService("Hub", true); } else { UnityConnectServiceCollection.instance.CloseServices(); } } } catch (Exception arg) { UnityEngine.Debug.LogError("Failed to load window layout: " + arg); switch (EditorUtility.DisplayDialogComplex("Failed to load window layout", "This can happen if layout contains custom windows and there are compile errors in the project.", "Load Default Layout", "Quit", "Revert Factory Settings")) { case 0: WindowLayout.LoadDefaultLayout(); break; case 1: EditorApplication.Exit(0); break; case 2: WindowLayout.RevertFactorySettings(); break; } return(false); } finally { ContainerWindow.SetFreezeDisplay(false); if (Path.GetExtension(path) == ".wlt") { Toolbar.lastLoadedLayoutName = Path.GetFileNameWithoutExtension(path); } else { Toolbar.lastLoadedLayoutName = null; } } return(true); }
internal static Vector2 GetSizeOfMainGameView() { return(GameView.GetMainGameViewTargetSize()); }
private void OnFocus() { this.AllowCursorLockAndHide(true); s_LastFocusedGameView = this; InternalEditorUtility.OnGameViewFocus(true); }
internal static GameView GetMainGameView() { if (((s_LastFocusedGameView == null) && (s_GameViews != null)) && (s_GameViews.Count > 0)) { s_LastFocusedGameView = s_GameViews[0]; } return s_LastFocusedGameView; }
private static void Clear() { m_MaximizePending = false; m_GameView = null; }
private static void Clear() { m_RootSplit = null; m_GameView = null; }
internal static GameView GetMainGameView() { if ((UnityEngine.Object) GameView.s_LastFocusedGameView == (UnityEngine.Object) null && GameView.s_GameViews != null && GameView.s_GameViews.Count > 0) GameView.s_LastFocusedGameView = GameView.s_GameViews[0]; return GameView.s_LastFocusedGameView; }
public override void OnInspectorGUI() { this.serializedObject.Update(); Camera target = (Camera)this.target; this.m_ShowBGColorOptions.target = !this.m_ClearFlags.hasMultipleDifferentValues && (target.clearFlags == CameraClearFlags.Color || target.clearFlags == CameraClearFlags.Skybox); this.m_ShowOrthoOptions.target = !this.m_Orthographic.hasMultipleDifferentValues && target.orthographic; this.m_ShowTargetEyeOption.target = this.m_TargetEye.intValue != 3 || PlayerSettings.virtualRealitySupported || PlayerSettings.stereoscopic3D; EditorGUILayout.PropertyField(this.m_ClearFlags); if (EditorGUILayout.BeginFadeGroup(this.m_ShowBGColorOptions.faded)) { EditorGUILayout.PropertyField(this.m_BackgroundColor, new GUIContent("Background", "Camera clears the screen to this color before rendering."), new GUILayoutOption[0]); } EditorGUILayout.EndFadeGroup(); EditorGUILayout.PropertyField(this.m_CullingMask); EditorGUILayout.Space(); CameraEditor.ProjectionType projectionType1 = !this.m_Orthographic.boolValue ? CameraEditor.ProjectionType.Perspective : CameraEditor.ProjectionType.Orthographic; EditorGUI.BeginChangeCheck(); EditorGUI.showMixedValue = this.m_Orthographic.hasMultipleDifferentValues; CameraEditor.ProjectionType projectionType2 = (CameraEditor.ProjectionType)EditorGUILayout.EnumPopup("Projection", (Enum)projectionType1, new GUILayoutOption[0]); EditorGUI.showMixedValue = false; if (EditorGUI.EndChangeCheck()) { this.m_Orthographic.boolValue = projectionType2 == CameraEditor.ProjectionType.Orthographic; } if (!this.m_Orthographic.hasMultipleDifferentValues) { if (EditorGUILayout.BeginFadeGroup(this.m_ShowOrthoOptions.faded)) { EditorGUILayout.PropertyField(this.m_OrthographicSize, new GUIContent("Size"), new GUILayoutOption[0]); } EditorGUILayout.EndFadeGroup(); if (EditorGUILayout.BeginFadeGroup(1f - this.m_ShowOrthoOptions.faded)) { EditorGUILayout.Slider(this.m_FieldOfView, 1f, 179f, new GUIContent("Field of View"), new GUILayoutOption[0]); } EditorGUILayout.EndFadeGroup(); } EditorGUILayout.PropertiesField(EditorGUI.s_ClipingPlanesLabel, this.m_NearAndFarClippingPlanes, EditorGUI.s_NearAndFarLabels, 35f); EditorGUILayout.PropertyField(this.m_NormalizedViewPortRect, this.m_ViewportLabel, new GUILayoutOption[0]); EditorGUILayout.Space(); EditorGUILayout.PropertyField(this.m_Depth); EditorGUILayout.IntPopup(this.m_RenderingPath, CameraEditor.kCameraRenderPaths, CameraEditor.kCameraRenderPathValues, EditorGUIUtility.TempContent("Rendering Path"), new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_TargetTexture); EditorGUILayout.PropertyField(this.m_OcclusionCulling); EditorGUILayout.PropertyField(this.m_HDR); if (this.m_HDR.boolValue) { this.DisplayHDRWarnings(); } if (PlayerSettings.stereoscopic3D) { EditorGUILayout.PropertyField(this.m_StereoSeparation); EditorGUILayout.PropertyField(this.m_StereoConvergence); } if (this.ShouldShowTargetDisplayProperty()) { int intValue = this.m_TargetDisplay.intValue; EditorGUILayout.Space(); EditorGUILayout.IntPopup(this.m_TargetDisplay, DisplayUtility.GetDisplayNames(), DisplayUtility.GetDisplayIndices(), EditorGUIUtility.TempContent("Target Display"), new GUILayoutOption[0]); if (intValue != this.m_TargetDisplay.intValue) { GameView.RepaintAll(); } } if (EditorGUILayout.BeginFadeGroup(this.m_ShowTargetEyeOption.faded)) { EditorGUILayout.IntPopup(this.m_TargetEye, CameraEditor.kTargetEyes, CameraEditor.kTargetEyeValues, EditorGUIUtility.TempContent("Target Eye"), new GUILayoutOption[0]); } EditorGUILayout.EndFadeGroup(); this.DepthTextureModeGUI(); this.CommandBufferGUI(); this.serializedObject.ApplyModifiedProperties(); }
private static void GetMainGameViewTargetSizeNoBox(out Vector2 result) { result = GameView.GetMainGameViewTargetSize(); }
private void CommandBufferGUI() { // Command buffers are not serialized data, so can't get to them through // serialized property (hence no multi-edit). if (targets.Length != 1) { return; } var cam = target as Camera; if (cam == null) { return; } int count = cam.commandBufferCount; if (count == 0) { return; } m_CommandBuffersShown = GUILayout.Toggle(m_CommandBuffersShown, GUIContent.Temp(count + " command buffers"), EditorStyles.foldout); if (!m_CommandBuffersShown) { return; } EditorGUI.indentLevel++; foreach (CameraEvent ce in (CameraEvent[])System.Enum.GetValues(typeof(CameraEvent))) { CommandBuffer[] cbs = cam.GetCommandBuffers(ce); foreach (CommandBuffer cb in cbs) { using (new GUILayout.HorizontalScope()) { // row with event & command buffer information label Rect rowRect = GUILayoutUtility.GetRect(GUIContent.none, EditorStyles.miniLabel); rowRect.xMin += EditorGUI.indent; Rect minusRect = GetRemoveButtonRect(rowRect); rowRect.xMax = minusRect.x; GUI.Label(rowRect, string.Format("{0}: {1} ({2})", ce, cb.name, EditorUtility.FormatBytes(cb.sizeInBytes)), EditorStyles.miniLabel); // and a button to remove it if (GUI.Button(minusRect, Styles.iconRemove, Styles.invisibleButton)) { cam.RemoveCommandBuffer(ce, cb); SceneView.RepaintAll(); GameView.RepaintAll(); GUIUtility.ExitGUI(); } } } } // "remove all" button using (new GUILayout.HorizontalScope()) { GUILayout.FlexibleSpace(); if (GUILayout.Button("Remove all", EditorStyles.miniButton)) { cam.RemoveAllCommandBuffers(); SceneView.RepaintAll(); GameView.RepaintAll(); } } EditorGUI.indentLevel--; }
private void OnFocus() { GameView.s_LastFocusedGameView = this; InternalEditorUtility.OnGameViewFocus(true); }
internal static Rect GetConstrainedGameViewRenderRect(Rect renderRect, int sizeIndex) { bool flag; return(GameView.GetConstrainedGameViewRenderRect(renderRect, sizeIndex, out flag)); }
private void OnGUI() { if (GameView.s_GizmoButtonStyle == null) { GameView.s_GizmoButtonStyle = "GV Gizmo DropDown"; GameView.s_ResolutionWarningStyle = new GUIStyle("PreOverlayLabel"); GameView.s_ResolutionWarningStyle.alignment = TextAnchor.UpperLeft; GameView.s_ResolutionWarningStyle.padding = new RectOffset(6, 6, 1, 1); } this.DoToolbarGUI(); Rect gameViewRenderRect = this.gameViewRenderRect; bool fitsInsideRect; Rect constrainedGameViewRenderRect = GameView.GetConstrainedGameViewRenderRect(gameViewRenderRect, this.selectedSizeIndex, out fitsInsideRect); Rect rect = GUIClip.Unclip(constrainedGameViewRenderRect); base.SetInternalGameViewRect(rect); EditorGUIUtility.AddCursorRect(constrainedGameViewRenderRect, MouseCursor.CustomCursor); EventType type = Event.current.type; if (type == EventType.MouseDown && gameViewRenderRect.Contains(Event.current.mousePosition)) { Unsupported.SetAllowCursorLock(true); Unsupported.SetAllowCursorHide(true); } else { if (type == EventType.KeyDown && Event.current.keyCode == KeyCode.Escape) { Unsupported.SetAllowCursorLock(false); } } if (type == EventType.Repaint) { if (!this.currentGameViewSize.isFreeAspectRatio || !InternalEditorUtility.HasFullscreenCamera()) { GUI.Box(gameViewRenderRect, GUIContent.none, "GameViewBackground"); } Vector2 s_EditorScreenPointOffset = GUIUtility.s_EditorScreenPointOffset; GUIUtility.s_EditorScreenPointOffset = Vector2.zero; SavedGUIState savedGUIState = SavedGUIState.Create(); if (Display.MultiDisplayLicense()) { EditorGUIUtility.RenderGameViewCameras(rect, this.m_TargetDisplay, this.m_Gizmos, true); } else { EditorGUIUtility.RenderGameViewCameras(rect, 0, this.m_Gizmos, true); } savedGUIState.ApplyAndForget(); GUIUtility.s_EditorScreenPointOffset = s_EditorScreenPointOffset; } else { if (type != EventType.Layout && type != EventType.Used) { if (WindowLayout.s_MaximizeKey.activated && (!EditorApplication.isPlaying || EditorApplication.isPaused)) { return; } bool flag = constrainedGameViewRenderRect.Contains(Event.current.mousePosition); if (Event.current.rawType == EventType.MouseDown && !flag) { return; } Event.current.mousePosition = new Vector2(Event.current.mousePosition.x - constrainedGameViewRenderRect.x, Event.current.mousePosition.y - constrainedGameViewRenderRect.y); EditorGUIUtility.QueueGameViewInputEvent(Event.current); bool flag2 = true; if (Event.current.rawType == EventType.MouseUp && !flag) { flag2 = false; } if (type == EventType.ExecuteCommand || type == EventType.ValidateCommand) { flag2 = false; } if (flag2) { Event.current.Use(); } else { Event.current.mousePosition = new Vector2(Event.current.mousePosition.x + constrainedGameViewRenderRect.x, Event.current.mousePosition.y + constrainedGameViewRenderRect.y); } } } this.ShowResolutionWarning(new Rect(gameViewRenderRect.x, gameViewRenderRect.y, 200f, 20f), fitsInsideRect, constrainedGameViewRenderRect.size); if (this.m_Stats) { GameViewGUI.GameViewStatsGUI(); } }
private void MaterialListing() { ProceduralMaterial[] sortedMaterials = this.GetSortedMaterials(); foreach (ProceduralMaterial proceduralMaterial in sortedMaterials) { if (proceduralMaterial.isProcessing) { this.Repaint(); SceneView.RepaintAll(); GameView.RepaintAll(); break; } } int length = sortedMaterials.Length; float num1 = (float)((double)GUIView.current.position.width - 16.0 - 18.0 - 2.0); if ((double)num1 * 2.0 < (double)length * 60.0) { num1 -= 16f; } int num2 = Mathf.Max(1, Mathf.FloorToInt(num1 / 60f)); int num3 = Mathf.CeilToInt((float)length / (float)num2); Rect viewRect = new Rect(0.0f, 0.0f, (float)num2 * 60f, (float)num3 * 76f); Rect rect = GUILayoutUtility.GetRect(viewRect.width, Mathf.Clamp(viewRect.height, 76f, 152f) + 1f); Rect position1 = new Rect(rect.x + 1f, rect.y + 1f, rect.width - 2f, rect.height - 1f); GUI.Box(rect, GUIContent.none, this.m_SubstanceStyles.gridBackground); GUI.Box(position1, GUIContent.none, this.m_SubstanceStyles.background); this.m_ListScroll = GUI.BeginScrollView(position1, this.m_ListScroll, viewRect, false, false); if (this.m_EditorCache == null) { this.m_EditorCache = new EditorCache(EditorFeatures.PreviewGUI); } for (int index = 0; index < sortedMaterials.Length; ++index) { ProceduralMaterial proceduralMaterial = sortedMaterials[index]; if (!((UnityEngine.Object)proceduralMaterial == (UnityEngine.Object)null)) { Rect position2 = new Rect((float)(index % num2) * 60f, (float)(index / num2) * 76f, 60f, 76f); bool flag = proceduralMaterial.name == this.m_SelectedMaterialInstanceName; Event current = Event.current; int controlId = GUIUtility.GetControlID(SubstanceImporterInspector.previewNoDragDropHash, FocusType.Native, position2); switch (current.GetTypeForControl(controlId)) { case EventType.MouseDown: if (current.button == 0 && position2.Contains(current.mousePosition)) { if (current.clickCount == 1) { this.m_SelectedMaterialInstanceName = proceduralMaterial.name; current.Use(); break; } if (current.clickCount == 2) { AssetDatabase.OpenAsset((UnityEngine.Object)proceduralMaterial); GUIUtility.ExitGUI(); current.Use(); break; } break; } break; case EventType.Repaint: Rect position3 = position2; position3.y = position2.yMax - 16f; position3.height = 16f; this.m_SubstanceStyles.resultsGridLabel.Draw(position3, EditorGUIUtility.TempContent(proceduralMaterial.name), false, false, flag, flag); break; } position2.height -= 16f; this.m_EditorCache[(UnityEngine.Object)proceduralMaterial].OnPreviewGUI(position2, this.m_SubstanceStyles.background); } } GUI.EndScrollView(); }
private static void Clear() { EditorApplicationLayout.m_RootSplit = (View)null; EditorApplicationLayout.m_GameView = (GameView)null; }
public RenderingGameView(GameView gameView) { GameView.s_RenderingGameView = gameView; }
private static void Clear() { EditorApplicationLayout.m_RootSplit = null; EditorApplicationLayout.m_GameView = null; }
private static void Clear() { EditorApplicationLayout.m_MaximizePending = false; EditorApplicationLayout.m_GameView = null; }
private void BuiltinCustomSplashScreenGUI() { EditorGUILayout.LabelField(k_Texts.splashTitle, EditorStyles.boldLabel); using (new EditorGUI.DisabledScope(!licenseAllowsDisabling)) { EditorGUILayout.PropertyField(m_ShowUnitySplashScreen, k_Texts.showSplash); if (!m_ShowUnitySplashScreen.boolValue) { return; } } GUIContent buttonLabel = SplashScreen.isFinished ? k_Texts.previewSplash : k_Texts.cancelPreviewSplash; Rect previewButtonRect = GUILayoutUtility.GetRect(buttonLabel, "button"); previewButtonRect = EditorGUI.PrefixLabel(previewButtonRect, new GUIContent(" ")); if (GUI.Button(previewButtonRect, buttonLabel)) { if (SplashScreen.isFinished) { SplashScreen.Begin(); PlayModeView.RepaintAll(); var playModeView = PlayModeView.GetMainPlayModeView(); if (playModeView) { playModeView.Focus(); } EditorApplication.update += PollSplashState; } else { SplashScreen.Stop(SplashScreen.StopBehavior.StopImmediate); EditorApplication.update -= PollSplashState; } GameView.RepaintAll(); } EditorGUILayout.PropertyField(m_SplashScreenLogoStyle, k_Texts.splashStyle); // Animation EditorGUILayout.PropertyField(m_SplashScreenAnimation, k_Texts.animate); m_ShowAnimationControlsAnimator.target = m_SplashScreenAnimation.intValue == (int)PlayerSettings.SplashScreen.AnimationMode.Custom; if (EditorGUILayout.BeginFadeGroup(m_ShowAnimationControlsAnimator.faded)) { EditorGUI.indentLevel++; EditorGUILayout.Slider(m_SplashScreenLogoAnimationZoom, 0.0f, 1.0f, k_Texts.logoZoom); EditorGUILayout.Slider(m_SplashScreenBackgroundAnimationZoom, 0.0f, 1.0f, k_Texts.backgroundZoom); EditorGUI.indentLevel--; } EditorGUILayout.EndFadeGroup(); EditorGUILayout.Space(); // Logos EditorGUILayout.LabelField(k_Texts.logosTitle, EditorStyles.boldLabel); using (new EditorGUI.DisabledScope(!Application.HasProLicense())) { EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(m_ShowUnitySplashLogo, k_Texts.showLogo); if (EditorGUI.EndChangeCheck()) { if (!m_ShowUnitySplashLogo.boolValue) { RemoveUnityLogoFromLogosList(); } else if (m_SplashScreenDrawMode.intValue == (int)PlayerSettings.SplashScreen.DrawMode.AllSequential) { AddUnityLogoToLogosList(); } } m_ShowLogoControlsAnimator.target = m_ShowUnitySplashLogo.boolValue; } if (EditorGUILayout.BeginFadeGroup(m_ShowLogoControlsAnimator.faded)) { EditorGUI.BeginChangeCheck(); var oldDrawmode = m_SplashScreenDrawMode.intValue; EditorGUILayout.PropertyField(m_SplashScreenDrawMode, k_Texts.drawMode); if (oldDrawmode != m_SplashScreenDrawMode.intValue) { if (m_SplashScreenDrawMode.intValue == (int)PlayerSettings.SplashScreen.DrawMode.UnityLogoBelow) { RemoveUnityLogoFromLogosList(); } else { AddUnityLogoToLogosList(); } } } EditorGUILayout.EndFadeGroup(); m_LogoList.DoLayoutList(); EditorGUILayout.Space(); // Background EditorGUILayout.LabelField(k_Texts.backgroundTitle, EditorStyles.boldLabel); EditorGUILayout.Slider(m_SplashScreenOverlayOpacity, Application.HasProLicense() ? k_MinProEditionOverlayOpacity : k_MinPersonalEditionOverlayOpacity, 1.0f, k_Texts.overlayOpacity); m_ShowBackgroundColorAnimator.target = m_SplashScreenBackgroundLandscape.objectReferenceValue == null; if (EditorGUILayout.BeginFadeGroup(m_ShowBackgroundColorAnimator.faded)) { EditorGUILayout.PropertyField(m_SplashScreenBackgroundColor, k_Texts.backgroundColor); } EditorGUILayout.EndFadeGroup(); EditorGUILayout.PropertyField(m_SplashScreenBlurBackground, k_Texts.blurBackground); EditorGUI.BeginChangeCheck(); ObjectReferencePropertyField <Sprite>(m_SplashScreenBackgroundLandscape, k_Texts.backgroundImage); if (EditorGUI.EndChangeCheck() && m_SplashScreenBackgroundLandscape.objectReferenceValue == null) { m_SplashScreenBackgroundPortrait.objectReferenceValue = null; } using (new EditorGUI.DisabledScope(m_SplashScreenBackgroundLandscape.objectReferenceValue == null)) { ObjectReferencePropertyField <Sprite>(m_SplashScreenBackgroundPortrait, k_Texts.backgroundPortraitImage); } }
private void CommandBufferGUI() { if (base.targets.Length != 1) { return; } Camera camera = this.target as Camera; if (camera == null) { return; } int commandBufferCount = camera.commandBufferCount; if (commandBufferCount == 0) { return; } this.m_CommandBuffersShown = GUILayout.Toggle(this.m_CommandBuffersShown, GUIContent.Temp(commandBufferCount + " command buffers"), EditorStyles.foldout, new GUILayoutOption[0]); if (!this.m_CommandBuffersShown) { return; } EditorGUI.indentLevel++; CameraEvent[] array = (CameraEvent[])Enum.GetValues(typeof(CameraEvent)); for (int i = 0; i < array.Length; i++) { CameraEvent cameraEvent = array[i]; CommandBuffer[] commandBuffers = camera.GetCommandBuffers(cameraEvent); CommandBuffer[] array2 = commandBuffers; for (int j = 0; j < array2.Length; j++) { CommandBuffer commandBuffer = array2[j]; using (new GUILayout.HorizontalScope(new GUILayoutOption[0])) { Rect rect = GUILayoutUtility.GetRect(GUIContent.none, EditorStyles.miniLabel); rect.xMin += EditorGUI.indent; Rect removeButtonRect = CameraEditor.GetRemoveButtonRect(rect); rect.xMax = removeButtonRect.x; GUI.Label(rect, string.Format("{0}: {1} ({2})", cameraEvent, commandBuffer.name, EditorUtility.FormatBytes(commandBuffer.sizeInBytes)), EditorStyles.miniLabel); if (GUI.Button(removeButtonRect, CameraEditor.Styles.iconRemove, CameraEditor.Styles.invisibleButton)) { camera.RemoveCommandBuffer(cameraEvent, commandBuffer); SceneView.RepaintAll(); GameView.RepaintAll(); GUIUtility.ExitGUI(); } } } } using (new GUILayout.HorizontalScope(new GUILayoutOption[0])) { GUILayout.FlexibleSpace(); if (GUILayout.Button("Remove all", EditorStyles.miniButton, new GUILayoutOption[0])) { camera.RemoveAllCommandBuffers(); SceneView.RepaintAll(); GameView.RepaintAll(); } } EditorGUI.indentLevel--; }
public static bool LoadWindowLayout(string path, bool newProjectLayoutWasCreated) { Rect position = default(Rect); UnityEngine.Object[] array = Resources.FindObjectsOfTypeAll(typeof(ContainerWindow)); UnityEngine.Object[] array2 = array; for (int i = 0; i < array2.Length; i++) { ContainerWindow containerWindow = (ContainerWindow)array2[i]; if (containerWindow.showMode == ShowMode.MainWindow) { position = containerWindow.position; } } try { ContainerWindow.SetFreezeDisplay(true); WindowLayout.CloseWindows(); UnityEngine.Object[] array3 = InternalEditorUtility.LoadSerializedFileAndForget(path); ContainerWindow containerWindow2 = null; ContainerWindow containerWindow3 = null; UnityEngine.Object[] array4 = array3; for (int j = 0; j < array4.Length; j++) { UnityEngine.Object @object = array4[j]; ContainerWindow containerWindow4 = @object as ContainerWindow; if (containerWindow4 != null && containerWindow4.showMode == ShowMode.MainWindow) { containerWindow3 = containerWindow4; if ((double)position.width != 0.0) { containerWindow2 = containerWindow4; containerWindow2.position = position; } } } int num = 0; UnityEngine.Object[] array5 = array3; for (int k = 0; k < array5.Length; k++) { UnityEngine.Object object2 = array5[k]; if (object2 == null) { UnityEngine.Debug.LogError("Error while reading window layout: window #" + num + " is null"); throw new Exception(); } if (object2.GetType() == null) { UnityEngine.Debug.LogError(string.Concat(new object[] { "Error while reading window layout: window #", num, " type is null, instanceID=", object2.GetInstanceID() })); throw new Exception(); } if (newProjectLayoutWasCreated) { MethodInfo method = object2.GetType().GetMethod("OnNewProjectLayoutWasCreated", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { method.Invoke(object2, null); } } num++; } if (containerWindow2) { containerWindow2.position = position; containerWindow2.OnResize(); } if (containerWindow3 == null) { UnityEngine.Debug.LogError("Error while reading window layout: no main window found"); throw new Exception(); } containerWindow3.Show(containerWindow3.showMode, true, true); UnityEngine.Object[] array6 = array3; for (int l = 0; l < array6.Length; l++) { UnityEngine.Object object3 = array6[l]; EditorWindow editorWindow = object3 as EditorWindow; if (editorWindow) { editorWindow.minSize = editorWindow.minSize; } ContainerWindow containerWindow5 = object3 as ContainerWindow; if (containerWindow5 && containerWindow5 != containerWindow3) { containerWindow5.Show(containerWindow5.showMode, true, true); } } GameView gameView = WindowLayout.GetMaximizedWindow() as GameView; if (gameView != null && gameView.maximizeOnPlay) { WindowLayout.Unmaximize(gameView); } } catch (Exception arg) { UnityEngine.Debug.LogError("Failed to load window layout: " + arg); switch (EditorUtility.DisplayDialogComplex("Failed to load window layout", "This can happen if layout contains custom windows and there are compile errors in the project.", "Load Default Layout", "Quit", "Revert Factory Settings")) { case 0: WindowLayout.LoadDefaultLayout(); break; case 1: EditorApplication.Exit(0); break; case 2: WindowLayout.RevertFactorySettings(); break; } return(false); } finally { ContainerWindow.SetFreezeDisplay(false); if (Path.GetExtension(path) == ".wlt") { Toolbar.lastLoadedLayoutName = Path.GetFileNameWithoutExtension(path); } else { Toolbar.lastLoadedLayoutName = null; } } return(true); }
public void OnOverlayGUI(UnityEngine.Object target, SceneView sceneView) { if (target == null) { return; } Camera camera = (Camera)target; Vector2 sizeOfMainGameView = GameView.GetSizeOfMainGameView(); if (sizeOfMainGameView.x < 0f) { sizeOfMainGameView.x = sceneView.position.width; sizeOfMainGameView.y = sceneView.position.height; } Rect rect = camera.rect; sizeOfMainGameView.x *= Mathf.Max(rect.width, 0f); sizeOfMainGameView.y *= Mathf.Max(rect.height, 0f); if (sizeOfMainGameView.x <= 0f || sizeOfMainGameView.y <= 0f) { return; } float num = sizeOfMainGameView.x / sizeOfMainGameView.y; sizeOfMainGameView.y = 0.2f * sceneView.position.height; sizeOfMainGameView.x = sizeOfMainGameView.y * num; if (sizeOfMainGameView.y > sceneView.position.height * 0.5f) { sizeOfMainGameView.y = sceneView.position.height * 0.5f; sizeOfMainGameView.x = sizeOfMainGameView.y * num; } if (sizeOfMainGameView.x > sceneView.position.width * 0.5f) { sizeOfMainGameView.x = sceneView.position.width * 0.5f; sizeOfMainGameView.y = sizeOfMainGameView.x / num; } Rect rect2 = GUILayoutUtility.GetRect(sizeOfMainGameView.x, sizeOfMainGameView.y); rect2 = EditorGUIUtility.PointsToPixels(rect2); rect2.y = (sceneView.position.height + 1f) * EditorGUIUtility.pixelsPerPoint - rect2.y - rect2.height; if (Event.current.type == EventType.Repaint) { this.previewCamera.CopyFrom(camera); Skybox component = this.previewCamera.GetComponent <Skybox>(); if (component) { Skybox component2 = camera.GetComponent <Skybox>(); if (component2 && component2.enabled) { component.enabled = true; component.material = component2.material; } else { component.enabled = false; } } this.previewCamera.targetTexture = null; this.previewCamera.pixelRect = rect2; Handles.EmitGUIGeometryForCamera(camera, this.previewCamera); this.previewCamera.Render(); } }
public void OnOverlayGUI(UnityEngine.Object target, SceneView sceneView) { if (target == (UnityEngine.Object)null) { return; } Camera camera = (Camera)target; Vector2 sizeOfMainGameView = GameView.GetSizeOfMainGameView(); if ((double)sizeOfMainGameView.x < 0.0) { sizeOfMainGameView.x = sceneView.position.width; sizeOfMainGameView.y = sceneView.position.height; } Rect rect = camera.rect; sizeOfMainGameView.x *= Mathf.Max(rect.width, 0.0f); sizeOfMainGameView.y *= Mathf.Max(rect.height, 0.0f); if ((double)sizeOfMainGameView.x <= 0.0 || (double)sizeOfMainGameView.y <= 0.0) { return; } float num = sizeOfMainGameView.x / sizeOfMainGameView.y; sizeOfMainGameView.y = 0.2f * sceneView.position.height; sizeOfMainGameView.x = sizeOfMainGameView.y * num; if ((double)sizeOfMainGameView.y > (double)sceneView.position.height * 0.5) { sizeOfMainGameView.y = sceneView.position.height * 0.5f; sizeOfMainGameView.x = sizeOfMainGameView.y * num; } if ((double)sizeOfMainGameView.x > (double)sceneView.position.width * 0.5) { sizeOfMainGameView.x = sceneView.position.width * 0.5f; sizeOfMainGameView.y = sizeOfMainGameView.x / num; } Rect pixels = EditorGUIUtility.PointsToPixels(GUILayoutUtility.GetRect(sizeOfMainGameView.x, sizeOfMainGameView.y)); pixels.y = (sceneView.position.height + 1f) * EditorGUIUtility.pixelsPerPoint - pixels.y - pixels.height; if (Event.current.type != EventType.Repaint) { return; } this.previewCamera.CopyFrom(camera); Skybox component1 = this.previewCamera.GetComponent <Skybox>(); if ((bool)((UnityEngine.Object)component1)) { Skybox component2 = camera.GetComponent <Skybox>(); if ((bool)((UnityEngine.Object)component2) && component2.enabled) { component1.enabled = true; component1.material = component2.material; } else { component1.enabled = false; } } this.previewCamera.targetTexture = (RenderTexture)null; this.previewCamera.pixelRect = pixels; Handles.EmitGUIGeometryForCamera(camera, this.previewCamera); this.previewCamera.Render(); }
internal static Vector2 GetSizeOfMainGameView() { Rect gameViewRenderRect = GameView.GetMainGameViewRenderRect(); return(new Vector2(gameViewRenderRect.width, gameViewRenderRect.height)); }
public virtual void OnOverlayGUI(Object target, SceneView sceneView) { if (target == null) { return; } // cache some deep values var c = (Camera)target; Vector2 previewSize = c.targetTexture ? new Vector2(c.targetTexture.width, c.targetTexture.height) : GameView.GetMainGameViewTargetSize(); if (previewSize.x < 0f) { // Fallback to Scene View of not a valid game view size previewSize.x = sceneView.position.width; previewSize.y = sceneView.position.height; } // Apply normalizedviewport rect of camera Rect normalizedViewPortRect = c.rect; previewSize.x *= Mathf.Max(normalizedViewPortRect.width, 0f); previewSize.y *= Mathf.Max(normalizedViewPortRect.height, 0f); // Prevent using invalid previewSize if (previewSize.x < 1f || previewSize.y < 1f) { return; } float aspect = previewSize.x / previewSize.y; // Scale down (fit to scene view) previewSize.y = kPreviewNormalizedSize * sceneView.position.height; previewSize.x = previewSize.y * aspect; if (previewSize.y > sceneView.position.height * 0.5f) { previewSize.y = sceneView.position.height * 0.5f; previewSize.x = previewSize.y * aspect; } if (previewSize.x > sceneView.position.width * 0.5f) { previewSize.x = sceneView.position.width * 0.5f; previewSize.y = previewSize.x / aspect; } // Get and reserve rect Rect cameraRect = GUILayoutUtility.GetRect(previewSize.x, previewSize.y); if (Event.current.type == EventType.Repaint) { // setup camera and render previewCamera.CopyFrom(c); // also make sure to sync any Skybox component on the preview camera var dstSkybox = previewCamera.GetComponent <Skybox>(); if (dstSkybox) { var srcSkybox = c.GetComponent <Skybox>(); if (srcSkybox && srcSkybox.enabled) { dstSkybox.enabled = true; dstSkybox.material = srcSkybox.material; } else { dstSkybox.enabled = false; } } var previewTexture = GetPreviewTextureWithSize((int)cameraRect.width, (int)cameraRect.height); previewTexture.antiAliasing = Mathf.Max(1, QualitySettings.antiAliasing); previewCamera.targetTexture = previewTexture; previewCamera.pixelRect = new Rect(0, 0, cameraRect.width, cameraRect.height); Handles.EmitGUIGeometryForCamera(c, previewCamera); GL.sRGBWrite = QualitySettings.activeColorSpace == ColorSpace.Linear; if (c.usePhysicalProperties) { // when sensor size is reduced, the previous frame is still visible behing so we need to clear the texture before rendering. RenderTexture rt = RenderTexture.active; RenderTexture.active = previewTexture; GL.Clear(false, true, Color.clear); RenderTexture.active = rt; } previewCamera.Render(); GL.sRGBWrite = false; Graphics.DrawTexture(cameraRect, previewTexture, new Rect(0, 0, 1, 1), 0, 0, 0, 0, GUI.color, EditorGUIUtility.GUITextureBlit2SRGBMaterial); } }
private void GameViewAspectWasChanged() { this.SetInternalGameViewRect(GameView.GetConstrainedGameViewRenderRect(this.gameViewRenderRect, this.selectedSizeIndex)); EditorApplication.SetSceneRepaintDirty(); }
public static bool LoadWindowLayout(string path, bool newProjectLayoutWasCreated, bool setLastLoadedLayoutName, bool keepMainWindow) { Rect mainWindowPosition = new Rect(); UnityObject[] containers = Resources.FindObjectsOfTypeAll(typeof(ContainerWindow)); foreach (ContainerWindow window in containers) { if (window.showMode == ShowMode.MainWindow) { mainWindowPosition = window.position; } } bool layoutLoadingIssue = false; // Load new windows and show them try { ContainerWindow.SetFreezeDisplay(true); CloseWindows(keepMainWindow); ContainerWindow mainWindowToSetSize = null; ContainerWindow mainWindow = null; UnityObject[] remainingContainers = Resources.FindObjectsOfTypeAll(typeof(ContainerWindow)); foreach (ContainerWindow window in remainingContainers) { if (mainWindow == null && window.showMode == ShowMode.MainWindow) { mainWindow = window; } else { window.Close(); } } // Load data UnityObject[] loadedWindows = InternalEditorUtility.LoadSerializedFileAndForget(path); if (loadedWindows == null || loadedWindows.Length == 0) { throw new ArgumentException("Window layout at '" + path + "' could not be loaded."); } List <UnityObject> newWindows = new List <UnityObject>(); // At this point, unparented editor windows are neither desired nor desirable. // This can be caused by (legacy) serialization of FallbackEditorWindows or // other serialization hiccups (note that unparented editor windows should not exist in theory). // Same goes for empty DockAreas (no panes). Leave them behind. for (int i = 0; i < loadedWindows.Length; i++) { UnityObject o = loadedWindows[i]; EditorWindow editorWin = o as EditorWindow; if (editorWin != null) { if (editorWin.m_Parent == null) { UnityObject.DestroyImmediate(editorWin, true); Console.WriteLine("LoadWindowLayout: Removed unparented EditorWindow while reading window layout: window #" + i + ", type=" + o.GetType() + ", instanceID=" + o.GetInstanceID()); layoutLoadingIssue = true; continue; } } else { ContainerWindow cw = o as ContainerWindow; if (cw != null && cw.rootView == null) { cw.Close(); UnityObject.DestroyImmediate(cw, true); continue; } DockArea dockArea = o as DockArea; if (dockArea != null && dockArea.m_Panes.Count == 0) { dockArea.Close(null); UnityObject.DestroyImmediate(dockArea, true); continue; } // Host views that donot hold any containers are not desirable at this stage HostView hostview = o as HostView; if (hostview != null && hostview.actualView == null) { UnityObject.DestroyImmediate(hostview, true); continue; } } newWindows.Add(o); } for (int i = 0; i < newWindows.Count; i++) { ContainerWindow cur = newWindows[i] as ContainerWindow; if (cur != null && cur.showMode == ShowMode.MainWindow) { if (mainWindow == null) { mainWindow = cur; } else { mainWindow.rootView = cur.rootView; UnityObject.DestroyImmediate(cur, true); cur = mainWindow; newWindows[i] = null; } if (mainWindowPosition.width != 0.0) { mainWindowToSetSize = cur; mainWindowToSetSize.position = mainWindowPosition; } break; } } for (int i = 0; i < newWindows.Count; i++) { UnityObject o = newWindows[i]; if (o == null) { continue; } if (o.GetType() == null) { Console.WriteLine("LoadWindowLayout: Error while reading window layout: window #" + i + " type is null, instanceID=" + o.GetInstanceID()); layoutLoadingIssue = true; // Keep going } else { if (newProjectLayoutWasCreated) { MethodInfo method = o.GetType().GetMethod("OnNewProjectLayoutWasCreated", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); if (method != null) { method.Invoke(o, null); } } } } if (mainWindowToSetSize) { mainWindowToSetSize.position = mainWindowPosition; mainWindowToSetSize.OnResize(); } // Always show main window before other windows. So that other windows can // get their parent/owner. if (mainWindow == null) { Debug.LogError("Error while reading window layout: no main window found"); throw new Exception(); } mainWindow.Show(mainWindow.showMode, loadPosition: true, displayImmediately: true, setFocus: true); // Show other windows for (int i = 0; i < newWindows.Count; i++) { if (newWindows[i] == null) { continue; } EditorWindow win = newWindows[i] as EditorWindow; if (win) { win.minSize = win.minSize; // Causes minSize to be propagated upwards to parents! } ContainerWindow containerWindow = newWindows[i] as ContainerWindow; if (containerWindow && containerWindow != mainWindow) { containerWindow.Show(containerWindow.showMode, loadPosition: false, displayImmediately: true, setFocus: true); } } // Unmaximize maximized GameView if maximize on play is enabled GameView gameView = GetMaximizedWindow() as GameView; if (gameView != null && gameView.maximizeOnPlay) { Unmaximize(gameView); } } catch (Exception ex) { Debug.LogError("Failed to load window layout: " + ex); int option = 0; UnityObject[] containerWindows = Resources.FindObjectsOfTypeAll(typeof(ContainerWindow)); // Only show dialog if an actual window is present. If not, revert to default immediately if (!Application.isTestRun && containerWindows.Length > 0) { option = EditorUtility.DisplayDialogComplex("Failed to load window layout", "This can happen if layout contains custom windows and there are compile errors in the project.", "Load Default Layout", "Quit", "Revert Factory Settings"); } switch (option) { case 0: LoadDefaultLayout(); break; case 1: EditorApplication.Exit(0); break; case 2: RevertFactorySettings(); break; } return(false); } finally { ContainerWindow.SetFreezeDisplay(false); if (setLastLoadedLayoutName && Path.GetExtension(path) == ".wlt") { Toolbar.lastLoadedLayoutName = Path.GetFileNameWithoutExtension(path); } else { Toolbar.lastLoadedLayoutName = null; } } if (layoutLoadingIssue) { Debug.Log("The editor layout could not be fully loaded, this can happen when the layout contains EditorWindows not available in this project"); } return(true); }
internal static Rect GetConstrainedGameViewRenderRect(Rect renderRect, int sizeIndex) { bool fitsInsideRect; return(GameView.GetConstrainedGameViewRenderRect(renderRect, sizeIndex, out fitsInsideRect)); }
private void BuiltinCustomSplashScreenGUI() { EditorGUILayout.LabelField(PlayerSettingsSplashScreenEditor.k_Texts.splashTitle, EditorStyles.boldLabel, new GUILayoutOption[0]); using (new EditorGUI.DisabledScope(!PlayerSettingsSplashScreenEditor.licenseAllowsDisabling)) { EditorGUILayout.PropertyField(this.m_ShowUnitySplashScreen, PlayerSettingsSplashScreenEditor.k_Texts.showSplash, new GUILayoutOption[0]); if (!this.m_ShowUnitySplashScreen.boolValue) { return; } } Rect rect = GUILayoutUtility.GetRect(PlayerSettingsSplashScreenEditor.k_Texts.previewSplash, "button"); rect = EditorGUI.PrefixLabel(rect, new GUIContent(" ")); if (GUI.Button(rect, PlayerSettingsSplashScreenEditor.k_Texts.previewSplash)) { SplashScreen.Begin(); GameView mainGameView = GameView.GetMainGameView(); if (mainGameView) { mainGameView.Focus(); } GameView.RepaintAll(); } EditorGUILayout.PropertyField(this.m_SplashScreenLogoStyle, PlayerSettingsSplashScreenEditor.k_Texts.splashStyle, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_SplashScreenAnimation, PlayerSettingsSplashScreenEditor.k_Texts.animate, new GUILayoutOption[0]); this.m_ShowAnimationControlsAnimator.target = (this.m_SplashScreenAnimation.intValue == 2); if (EditorGUILayout.BeginFadeGroup(this.m_ShowAnimationControlsAnimator.faded)) { EditorGUI.indentLevel++; EditorGUILayout.Slider(this.m_SplashScreenLogoAnimationZoom, 0f, 1f, PlayerSettingsSplashScreenEditor.k_Texts.logoZoom, new GUILayoutOption[0]); EditorGUILayout.Slider(this.m_SplashScreenBackgroundAnimationZoom, 0f, 1f, PlayerSettingsSplashScreenEditor.k_Texts.backgroundZoom, new GUILayoutOption[0]); EditorGUI.indentLevel--; } EditorGUILayout.EndFadeGroup(); EditorGUILayout.Space(); EditorGUILayout.LabelField(PlayerSettingsSplashScreenEditor.k_Texts.logosTitle, EditorStyles.boldLabel, new GUILayoutOption[0]); using (new EditorGUI.DisabledScope(!Application.HasProLicense())) { EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(this.m_ShowUnitySplashLogo, PlayerSettingsSplashScreenEditor.k_Texts.showLogo, new GUILayoutOption[0]); if (EditorGUI.EndChangeCheck()) { if (!this.m_ShowUnitySplashLogo.boolValue) { this.RemoveUnityLogoFromLogosList(); } else if (this.m_SplashScreenDrawMode.intValue == 1) { this.AddUnityLogoToLogosList(); } } this.m_ShowLogoControlsAnimator.target = this.m_ShowUnitySplashLogo.boolValue; } if (EditorGUILayout.BeginFadeGroup(this.m_ShowLogoControlsAnimator.faded)) { EditorGUI.indentLevel++; EditorGUI.BeginChangeCheck(); int intValue = this.m_SplashScreenDrawMode.intValue; EditorGUILayout.PropertyField(this.m_SplashScreenDrawMode, PlayerSettingsSplashScreenEditor.k_Texts.drawMode, new GUILayoutOption[0]); if (intValue != this.m_SplashScreenDrawMode.intValue) { if (this.m_SplashScreenDrawMode.intValue == 0) { this.RemoveUnityLogoFromLogosList(); } else { this.AddUnityLogoToLogosList(); } } EditorGUI.indentLevel--; } EditorGUILayout.EndFadeGroup(); this.m_LogoList.DoLayoutList(); EditorGUILayout.Space(); EditorGUILayout.LabelField(PlayerSettingsSplashScreenEditor.k_Texts.backgroundTitle, EditorStyles.boldLabel, new GUILayoutOption[0]); EditorGUILayout.Slider(this.m_SplashScreenOverlayOpacity, (!Application.HasProLicense()) ? PlayerSettingsSplashScreenEditor.k_MinPersonalEditionOverlayOpacity : PlayerSettingsSplashScreenEditor.k_MinProEditionOverlayOpacity, 1f, PlayerSettingsSplashScreenEditor.k_Texts.overlayOpacity, new GUILayoutOption[0]); this.m_ShowBackgroundColorAnimator.target = (this.m_SplashScreenBackgroundLandscape.objectReferenceValue == null); if (EditorGUILayout.BeginFadeGroup(this.m_ShowBackgroundColorAnimator.faded)) { EditorGUILayout.PropertyField(this.m_SplashScreenBackgroundColor, PlayerSettingsSplashScreenEditor.k_Texts.backgroundColor, new GUILayoutOption[0]); } EditorGUILayout.EndFadeGroup(); PlayerSettingsSplashScreenEditor.ObjectReferencePropertyField <Sprite>(this.m_SplashScreenBackgroundLandscape, PlayerSettingsSplashScreenEditor.k_Texts.backgroundImage); if (GUI.changed && this.m_SplashScreenBackgroundLandscape.objectReferenceValue == null) { this.m_SplashScreenBackgroundPortrait.objectReferenceValue = null; } using (new EditorGUI.DisabledScope(this.m_SplashScreenBackgroundLandscape.objectReferenceValue == null)) { PlayerSettingsSplashScreenEditor.ObjectReferencePropertyField <Sprite>(this.m_SplashScreenBackgroundPortrait, PlayerSettingsSplashScreenEditor.k_Texts.backgroundPortraitImage); } }
private void OnGUI() { if (GameView.s_GizmoButtonStyle == null) { GameView.s_GizmoButtonStyle = (GUIStyle)"GV Gizmo DropDown"; GameView.s_ResolutionWarningStyle = new GUIStyle((GUIStyle)"PreOverlayLabel"); GameView.s_ResolutionWarningStyle.alignment = TextAnchor.UpperLeft; GameView.s_ResolutionWarningStyle.padding = new RectOffset(6, 6, 1, 1); } this.DoToolbarGUI(); Rect gameViewRenderRect1 = this.gameViewRenderRect; bool fitsInsideRect; Rect gameViewRenderRect2 = GameView.GetConstrainedGameViewRenderRect(EditorGUIUtility.PointsToPixels(gameViewRenderRect1), this.selectedSizeIndex, out fitsInsideRect); Rect points = EditorGUIUtility.PixelsToPoints(gameViewRenderRect2); Rect rect = GUIClip.Unclip(points); Rect pixels = EditorGUIUtility.PointsToPixels(rect); this.SetInternalGameViewRect(rect); EditorGUIUtility.AddCursorRect(points, MouseCursor.CustomCursor); EventType type = Event.current.type; if (type == EventType.MouseDown && gameViewRenderRect1.Contains(Event.current.mousePosition)) { this.AllowCursorLockAndHide(true); } else if (type == EventType.KeyDown && Event.current.keyCode == KeyCode.Escape) { Unsupported.SetAllowCursorLock(false); } if (type == EventType.Repaint) { if (!this.currentGameViewSize.isFreeAspectRatio || !InternalEditorUtility.HasFullscreenCamera() || !EditorGUIUtility.IsDisplayReferencedByCameras(this.m_TargetDisplay)) { GUI.Box(gameViewRenderRect1, GUIContent.none, (GUIStyle)"GameViewBackground"); if (!InternalEditorUtility.HasFullscreenCamera()) { float[] numArray = new float[3] { 30f, (float)((double)gameViewRenderRect1.height / 2.0 - 10.0), (float)((double)gameViewRenderRect1.height - 10.0) }; foreach (int num in numArray) { GUI.Label(new Rect((float)((double)gameViewRenderRect1.width / 2.0 - 100.0), (float)num, 300f, 20f), "Scene is missing a fullscreen camera", (GUIStyle)"WhiteLargeLabel"); } } } Vector2 screenPointOffset = GUIUtility.s_EditorScreenPointOffset; GUIUtility.s_EditorScreenPointOffset = Vector2.zero; SavedGUIState savedGuiState = SavedGUIState.Create(); if (this.ShouldShowMultiDisplayOption()) { EditorGUIUtility.RenderGameViewCamerasInternal(pixels, this.m_TargetDisplay, this.m_Gizmos, true); } else { EditorGUIUtility.RenderGameViewCamerasInternal(pixels, 0, this.m_Gizmos, true); } GL.sRGBWrite = false; savedGuiState.ApplyAndForget(); GUIUtility.s_EditorScreenPointOffset = screenPointOffset; } else if (type != EventType.Layout && type != EventType.Used) { if (WindowLayout.s_MaximizeKey.activated && (!EditorApplication.isPlaying || EditorApplication.isPaused)) { return; } bool flag1 = points.Contains(Event.current.mousePosition); if (Event.current.rawType == EventType.MouseDown && !flag1) { return; } Vector2 mousePosition = Event.current.mousePosition; Event.current.mousePosition = EditorGUIUtility.PointsToPixels(mousePosition - points.position); Event.current.displayIndex = this.m_TargetDisplay; EditorGUIUtility.QueueGameViewInputEvent(Event.current); bool flag2 = true; if (Event.current.rawType == EventType.MouseUp && !flag1) { flag2 = false; } if (type == EventType.ExecuteCommand || type == EventType.ValidateCommand) { flag2 = false; } if (flag2) { Event.current.Use(); } else { Event.current.mousePosition = mousePosition; } } this.ShowResolutionWarning(new Rect(gameViewRenderRect1.x, gameViewRenderRect1.y, 200f, 20f), fitsInsideRect, gameViewRenderRect2.size); if (!this.m_Stats) { return; } GameViewGUI.GameViewStatsGUI(); }
private void MaterialListing() { ProceduralMaterial[] sortedMaterials = this.GetSortedMaterials(); ProceduralMaterial[] array = sortedMaterials; for (int i = 0; i < array.Length; i++) { ProceduralMaterial proceduralMaterial = array[i]; if (proceduralMaterial.isProcessing) { base.Repaint(); SceneView.RepaintAll(); GameView.RepaintAll(); break; } } int num = sortedMaterials.Length; float num2 = GUIView.current.position.width - 16f - 18f - 2f; if (num2 * 2f < (float)num * 60f) { num2 -= 16f; } int num3 = Mathf.Max(1, Mathf.FloorToInt(num2 / 60f)); int num4 = Mathf.CeilToInt((float)num / (float)num3); Rect viewRect = new Rect(0f, 0f, (float)num3 * 60f, (float)num4 * 76f); Rect rect = GUILayoutUtility.GetRect(viewRect.width, Mathf.Clamp(viewRect.height, 76f, 152f) + 1f); Rect position = new Rect(rect.x + 1f, rect.y + 1f, rect.width - 2f, rect.height - 1f); GUI.Box(rect, GUIContent.none, this.m_SubstanceStyles.gridBackground); GUI.Box(position, GUIContent.none, this.m_SubstanceStyles.background); this.m_ListScroll = GUI.BeginScrollView(position, this.m_ListScroll, viewRect, false, false); if (this.m_EditorCache == null) { this.m_EditorCache = new EditorCache(EditorFeatures.PreviewGUI); } for (int j = 0; j < sortedMaterials.Length; j++) { ProceduralMaterial proceduralMaterial2 = sortedMaterials[j]; if (!(proceduralMaterial2 == null)) { float x = (float)(j % num3) * 60f; float y = (float)(j / num3) * 76f; Rect rect2 = new Rect(x, y, 60f, 76f); bool flag = proceduralMaterial2.name == this.m_SelectedMaterialInstanceName; Event current = Event.current; int controlID = GUIUtility.GetControlID(SubstanceImporterInspector.previewNoDragDropHash, FocusType.Passive, rect2); EventType typeForControl = current.GetTypeForControl(controlID); if (typeForControl != EventType.Repaint) { if (typeForControl == EventType.MouseDown) { if (current.button == 0) { if (rect2.Contains(current.mousePosition)) { if (current.clickCount == 1) { this.m_SelectedMaterialInstanceName = proceduralMaterial2.name; current.Use(); } else if (current.clickCount == 2) { AssetDatabase.OpenAsset(proceduralMaterial2); GUIUtility.ExitGUI(); current.Use(); } } } } } else { Rect position2 = rect2; position2.y = rect2.yMax - 16f; position2.height = 16f; this.m_SubstanceStyles.resultsGridLabel.Draw(position2, EditorGUIUtility.TempContent(proceduralMaterial2.name), false, false, flag, flag); } rect2.height -= 16f; EditorWrapper editorWrapper = this.m_EditorCache[proceduralMaterial2]; editorWrapper.OnPreviewGUI(rect2, this.m_SubstanceStyles.background); } } GUI.EndScrollView(); }
internal static GameView GetMainGameView() { if (GameView.s_LastFocusedGameView == null && GameView.s_GameViews != null && GameView.s_GameViews.Count > 0) { GameView.s_LastFocusedGameView = GameView.s_GameViews[0]; } return GameView.s_LastFocusedGameView; }