public void OnGUI() { this.OnTypeGUI(); EditorGUIUtility.labelWidth = 50f; GUILayout.BeginVertical(EditorStyles.helpBox); { this.OnContentGUI(); } GUILayout.EndVertical(); EditorGUIUtilityExt.LookLikeControls(); }
private void OnGUI() { if (m_Styles == null) { m_Styles = new Styles(); } EditorGUIUtilityExt.LookLikeControls(85, 0f); if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Return && CanCreate()) { Create(); } EditorGUILayout.BeginHorizontal(); { GUILayout.Space(10); PreviewGUI(); GUILayout.Space(10); EditorGUILayout.BeginVertical(); { OptionsGUI(); GUILayout.Space(10); //GUILayout.FlexibleSpace (); CreateAndCancelButtonsGUI(); } EditorGUILayout.EndVertical(); GUILayout.Space(10); } EditorGUILayout.EndHorizontal(); GUILayout.Space(10); // Clear keyboard focus if clicking a random place inside the dialog, // or if ClearKeyboardControl flag is set. if (m_ClearKeyboardControl || (Event.current.type == EventType.MouseDown && Event.current.button == 0)) { GUIUtility.keyboardControl = 0; m_ClearKeyboardControl = false; Repaint(); } }
public override void OnPreviewSettings() { base.OnPreviewSettings(); var comp = this.selectedComponent; if (comp != null && comp.tag != LayoutTag.None) { EditorGUIUtility.labelWidth = 100f; comp.component = EditorGUILayout.ObjectField(comp.description.ToLower().UppercaseWords(), comp.component, typeof(WindowComponent), false) as WindowComponent; if (GUILayout.Button("...") == true) { WindowComponentLibraryChooser.Show((element) => { comp.component = element.mainComponent; EditorUtility.SetDirty(comp.component); }); } EditorGUIUtilityExt.LookLikeControls(); } }
private void DrawPreferences(float width) { if (this.screenInstance != null) { var screen = this.screenInstance; if (screen != null) { EditorGUILayout.LabelField("Screen", EditorStyles.boldLabel); var prefs = screen.preferences; EditorGUIUtility.labelWidth = 50f; EditorGUILayout.HelpBox("By default all windows sorted by Z-Order and Camera's Depth. But you may need to show for example level loader at the top or put some window at the background (For example animated background).", MessageType.Info); var layer = (DepthLayer)EditorGUILayout.EnumPopup("Layer:", prefs.layer, GUILayout.Width(width)); if (layer != prefs.layer) { this.isScreenDirty = true; prefs.layer = layer; } EditorGUIUtility.labelWidth = 100f; /*EditorGUILayout.HelpBox("You may need to destroy windows automatic on new scene loaded. Set this toggle off to do it. By default its on.", MessageType.Info); * var dontDestroyOnLoad = EditorGUILayout.Toggle("Dont Destroy:", prefs.dontDestroyOnLoad, GUILayout.Width(width)); * if (dontDestroyOnLoad != prefs.dontDestroyOnLoad) { * * this.isScreenDirty = true; * prefs.dontDestroyOnLoad = dontDestroyOnLoad; * * }*/ EditorGUIUtilityExt.LookLikeControls(); var layoutScreen = screen as LayoutWindowType; if (this.layoutInstance != null && layoutScreen != null) { EditorGUILayout.Space(); EditorGUILayout.LabelField("Layout Fit", EditorStyles.boldLabel); var scaleMode = (WindowLayout.ScaleMode)EditorGUILayout.EnumPopup("", layoutScreen.layout.scaleMode); if (scaleMode != layoutScreen.layout.scaleMode) { layoutScreen.layout.scaleMode = scaleMode; this.isScreenDirty = true; this.isLayoutDirty = true; this.layoutInstance.SetScale(scaleMode, layoutScreen.layout.fixedScaleResolution, layoutScreen.layout.matchWidthOrHeight); } if (layoutScreen.layout.scaleMode == UnityEngine.UI.Windows.WindowLayout.ScaleMode.Custom) { EditorGUIUtility.labelWidth = 70f; if (this.layoutInstance.ValidateCanvasScaler() == true) { this.isLayoutDirty = true; } var scalerEditor = Editor.CreateEditor(this.layoutInstance.canvasScaler); scalerEditor.OnInspectorGUI(); if (GUI.changed == true) { this.isLayoutDirty = true; } EditorGUIUtilityExt.LookLikeControls(); } } } } }
public override void OnGUI() { if (Layout.styles == null) { Layout.styles = new Styles(); } if (this.opened == true) { const float settingsWidth = 320f; const float listHeight = 200f; const float padding = 5f; const float closeSize = 30f; const float scrollWidth = 16f; var rect = new Rect(0f, -OFFSET, Screen.width, Screen.height - OFFSET).PixelPerfect(); var rectContent = new Rect(rect.x + MARGIN + settingsWidth + padding, rect.y + MARGIN, rect.width - MARGIN * 2f - padding - settingsWidth, rect.height - MARGIN * 2f - FlowSystemEditorWindow.TOOLBAR_HEIGHT).PixelPerfect(); var rectList = new Rect(MARGIN, rect.y + MARGIN, settingsWidth, listHeight - padding).PixelPerfect(); var rectSettings = new Rect(MARGIN, rect.y + MARGIN + listHeight, settingsWidth, rect.height - MARGIN * 2f - FlowSystemEditorWindow.TOOLBAR_HEIGHT - listHeight).PixelPerfect(); var rectCloseButton = new Rect(rectContent.x + rectContent.width, rectContent.y - closeSize * 0.5f, closeSize, closeSize).PixelPerfect(); GUI.Box(new Rect(rect.x + MARGIN, rect.y + MARGIN, rect.width - MARGIN * 2f, rect.height - MARGIN * 2f - FlowSystemEditorWindow.TOOLBAR_HEIGHT).PixelPerfect(), string.Empty, Layout.styles.layoutBack); GUI.Box(rect, string.Empty, Layout.styles.backLock); GUI.Box(new Rect(0f, 0f, Screen.width, Screen.height).PixelPerfect(), string.Empty, Layout.styles.dropShadow); GUI.Box(rectList, string.Empty, Layout.styles.content); GUI.Box(rectSettings, string.Empty, Layout.styles.content); GUI.Box(rectContent, string.Empty, Layout.styles.contentScreen); GUI.BeginGroup(rectSettings); { if (this.component != null) { const float offsetTop = 50f; var viewRect = new Rect(0f, 0f, rectSettings.width, 0f).PixelPerfect(); var scrollView = new Rect(0f, 0f + offsetTop, rectSettings.width, rectSettings.height - offsetTop).PixelPerfect(); System.Action <WindowComponent> onChange = (WindowComponent component) => { //Debug.Log(component + "!=" + this.component.component); if (component != this.component.component) { this.component.componentParametersEditor = null; this.component.componentParameters = this.component.OnComponentChanged(this.screen, component); if (this.component.componentParameters != null) { var e = Editor.CreateEditor(this.component.componentParameters) as IParametersEditor; this.component.componentParametersEditor = e; } UnityEditor.EditorUtility.SetDirty(this.screen); } }; var c = EditorGUI.ObjectField(new Rect(5f, 5f, viewRect.width - 40f - 5f * 2f, 16f).PixelPerfect(), this.component.component, typeof(WindowComponent), allowSceneObjects: false) as WindowComponent; if (c != this.component.component) { onChange(c); } var nRect = new Rect(viewRect.width - 40f, 5f, 40f - 5f, 16f).PixelPerfect(); GUILayoutExt.DrawComponentChooser(nRect, this.screen.gameObject, this.component.component, (component) => { onChange(component); }); if (this.component.component != null) { var editor = this.component.componentParametersEditor; nRect.x = 5f; nRect.width = viewRect.width - 5f * 2f; nRect.y += nRect.height + 5f; this.component.sortingOrder = EditorGUI.IntField(nRect, new GUIContent("Sorting Order"), this.component.sortingOrder); if (editor != null) { var h = Mathf.Max(scrollView.height, (editor == null) ? 0f : editor.GetHeight()); viewRect = new Rect(scrollView.x, scrollView.y, viewRect.width - scrollWidth, h).PixelPerfect(); var oldSkin = GUI.skin; GUI.skin = FlowSystemEditorWindow.defaultSkin; this.settingsScrollPosition = GUI.BeginScrollView(scrollView, this.settingsScrollPosition, viewRect, false, true); GUI.skin = oldSkin; { if (editor != null) { EditorGUIUtility.labelWidth = 100f; //++EditorGUI.indentLevel; editor.OnParametersGUI(viewRect); //--EditorGUI.indentLevel; EditorGUIUtilityExt.LookLikeControls(); } } GUI.EndScrollView(); } else { GUI.Label(new Rect(0f, 0f, rectSettings.width - scrollWidth, rectSettings.height).PixelPerfect(), "Selected component have no parameters", EditorStyles.centeredGreyMiniLabel); } } } else { GUI.Label(new Rect(0f, 0f, rectSettings.width - scrollWidth, rectSettings.height).PixelPerfect(), "Select an Element", EditorStyles.centeredGreyMiniLabel); } } GUI.EndGroup(); GUI.BeginGroup(rectList); { const float itemHeight = 30f; this.highlighted.Clear(); var viewRect = new Rect(0f, 0f, rectList.width - scrollWidth, 0f).PixelPerfect(); this.allListHeight = 0f; for (int i = 0; i < this.props.Count; ++i) { var root = this.screen.layout.layout.GetRootByTag(this.screen.layout.components[i].tag); if (root.showInComponentsList == false) { continue; } if (this.screen.layout.components[i].component == null) { this.highlighted.Add(root); } this.allListHeight += itemHeight; } viewRect.height = Mathf.Max(rectList.height, this.allListHeight); var oldSkin = GUI.skin; GUI.skin = FlowSystemEditorWindow.defaultSkin; this.listScrollPosition = GUI.BeginScrollView(new Rect(0f, 0f, rectList.width, rectList.height).PixelPerfect(), this.listScrollPosition, viewRect, false, true); GUI.skin = oldSkin; { GUI.BeginGroup(viewRect); { var h = 0f; this.hovered = null; for (int i = 0; i < this.props.Count; ++i) { var root = this.screen.layout.layout.GetRootByTag(this.screen.layout.components[i].tag); if (root.showInComponentsList == false) { continue; } var r = new Rect(0f, h, viewRect.width, itemHeight).PixelPerfect(); h += r.height; var isSelected = (this.element == root); if (isSelected == true) { GUI.Label(r, this.screen.layout.components[i].description, Layout.styles.listButtonSelected); } else { //r.width -= scrollWidth; if (GUI.Button(r, this.screen.layout.components[i].description, Layout.styles.listButton) == true) { this.component = this.screen.layout.components.FirstOrDefault(c => c.tag == root.tag); this.element = root; } var inRect = rectList.Contains(Event.current.mousePosition - this.listScrollPosition + Vector2.up * 40f); if (GUI.enabled == true) { EditorGUIUtility.AddCursorRect(r, MouseCursor.Link); } if (r.Contains(Event.current.mousePosition) == true && inRect == true) { this.hovered = this.screen.layout.components[i]; } //r.width += scrollWidth; } //r.width -= scrollWidth; GUI.Label(r, this.screen.layout.components[i].tag.ToString(), Layout.styles.listTag); } } GUI.EndGroup(); } GUI.EndScrollView(); } GUI.EndGroup(); var selected = (this.hovered != null) ? this.screen.layout.layout.GetRootByTag(this.hovered.tag) : this.element; this.editor.OnPreviewGUI(Color.white, rectContent, Layout.styles.content, selected: selected, onSelection: (element) => { this.component = this.screen.layout.components.FirstOrDefault(c => c.tag == element.tag); this.element = element; }, highlighted: this.highlighted); if (GUI.Button(rectCloseButton, string.Empty, Layout.styles.closeButton) == true) { this.flowEditor.SetEnabled(); this.opened = false; } } }