private void ShowDebugWindow() { GUI.Box(rectDebugLogBackground, GUIContent.none, guiSkin.customStyles[0]); GUILayout.Space(24f); using (var areaScope = new GUILayout.AreaScope(rectDebugLogScroll)) { using (var scrollScope = new GUILayout.ScrollViewScope(scrollDebugPosition, guiSkin.scrollView)) { scrollScope.handleScrollWheel = true; scrollDebugPosition = scrollScope.scrollPosition; for (indexDebug = 0; indexDebug < log.Count; indexDebug++) { if (indexDebug > logCapacity) break; GUILayout.Label(log[indexDebug], guiSkin.label); } } } if (GUI.Button(rectDebugButtonClear, "Clear", guiSkin.button)) { ClearLogs(); } if (GUI.Button(rectDebugButtonFontInc, "A+", guiSkin.button)) { if (guiSkin.label.fontSize < 64) guiSkin.label.fontSize += 2; } if (GUI.Button(rectDebugButtonFontDesc, "A-", guiSkin.button)) { if (guiSkin.label.fontSize > 8) guiSkin.label.fontSize -= 2; } }
private void OnGUI() { //layout the button using (var areaScope = new GUILayout.AreaScope(new Rect(Screen.width - 150, Screen.height * 2 / 3, 100, 1000))) //(Screen.width - 130, 10, 100, 1000) { curMess = GUILayout.TextField(curMess); GUI.color = Color.yellow; if (GUILayout.Button("Send")) { if (!string.IsNullOrEmpty(curMess.Trim())) { playerPointer.GetComponent <PlayerNetworkHook>().CmdChatMess_clientToServer(curMess); //LNWHook put in the playInfo curMess = string.Empty; } } } //display list of string in the scope using (var areaScope = new GUILayout.AreaScope(new Rect(10, Screen.height * 2 / 3, Screen.width / 2, 1000))) //(Screen.width - 130, 10, 100, 1000) { foreach (string st in chatList) { GUILayout.Label(st); } } }
protected override void RowGUI(RowGUIArgs rowGUIArgs) { base.RowGUI(rowGUIArgs); int id = (rowGUIArgs.item as InteractionListLine <T>).unitID; bool isactive = links.ContainsKey(typeof(T)) && links[typeof(T)] != null && links[typeof(T)].First().GetInstanceID() == id; isactive = isactive || (_right && links.ContainsKey(typeof(T)) && links[typeof(T)].Where(r => r.GetInstanceID() == id).Count() > 0); if (isactive || this.IsSelected(rowGUIArgs.item.id)) { var rekt = rowGUIArgs.rowRect; var newRekt = new Rect(rekt.x, rekt.y, rekt.width * 0.1f, rekt.height); //GUILayout.BeginArea(newRekt); var scope = new GUILayout.AreaScope(newRekt); if ((rowGUIArgs.item as InteractionListLine <T>)._special) { if (isactive) { GUILayout.Box(new GUIContent(texIcon, "Selected"), EditorStyles.miniLabel); } else { if (GUILayout.Button(new GUIContent(texIcon, "Start Linking"), EditorStyles.miniButton)) { links.Add(typeof(T), (rowGUIArgs.item as InteractionListLine <T>).GetComponent() as Component); } } } GUILayout.EndArea(); } }
public void DrawWindow() { statChangesAsString = ""; statChangesToDisplay = ""; using (GUILayout.AreaScope scope = new GUILayout.AreaScope(windowRect, choiceName, GUI.skin.window)) { choiceName = EditorGUILayout.TextField(choiceName); if (GUILayout.Button("Add Stat Change")) { changeStatBy.Add(0); cityDataStats.Add(CityData.money); statsToChange.Add("money"); } GUILayout.BeginHorizontal(); GUILayout.Label("Stat Change"); GUILayout.Label("Stat To Change"); GUILayout.EndHorizontal(); if (statsToChange.Count == 0) { statChangesAsString = "No stat changes"; statChangesToDisplay = "No stat changes"; } else { statChangesAsString = "Stat Changes: \n"; } for (int i = 0; i < statsToChange.Count; i++) { changeStatBy[i] = EditorGUI.FloatField(new Rect(25, 75 + i * 25, 30, 20), changeStatBy[i]); cityDataStats[i] = (CityData)EditorGUI.EnumPopup(new Rect(100, 75 + i * 25, (windowRect.width - 10) - 100, 20), cityDataStats[i]); statsToChange[i] = cityDataAsString[(int)cityDataStats[i]]; statChangesAsString += changeStatBy[i].ToString() + " " + cityDataAsFormattedString[(int)cityDataStats[i]]; if (changeStatBy[i] < 0) { statChangesToDisplay += "- " + cityDataAsFormattedString[(int)cityDataStats[i]]; } else if (changeStatBy[i] > 0) { statChangesToDisplay += "+ " + cityDataAsFormattedString[(int)cityDataStats[i]]; } else { statChangesToDisplay += "= " + cityDataAsFormattedString[(int)cityDataStats[i]]; } if (i + 1 != statsToChange.Count) { statChangesAsString += "\n"; statChangesToDisplay += "\n"; } } } }
public override void OnToolGUI(EditorWindow window) { if (Selection.activeGameObject == null) { return; } if (currentSelection != Selection.activeGameObject) { // reset currentSelection = Selection.activeGameObject; if (rect.size.magnitude < .1f) { rect.size = new Vector2(10, 10); } rect.center = Selection.activeGameObject.transform.position; } Color rectColor = new Color(.52f, .76f, .86f); rect = RectHandleUtilities.DrawRectHandles(rect, currentSelection.transform.position.z, Handles.DotHandleCap, rectColor, Color.clear, 0.1F * HandleUtility.GetHandleSize(currentSelection.transform.position), 0f); Handles.BeginGUI(); using (var area = new GUILayout.AreaScope(new Rect(20, 20, 300f, 200f))) { using (var vert = new GUILayout.VerticalScope()) { minDist = EditorGUILayout.FloatField("Min Dist", minDist); maxDist = EditorGUILayout.FloatField("Max Dist", maxDist); if (GUILayout.Button("Distribute!")) { var dist = new PoissonDiscSampler(rect.width, rect.height, minDist, maxDist); int undoId = Undo.GetCurrentGroup(); foreach (var point in dist.Samples()) { Vector3 pos = rect.min + point; pos.z = currentSelection.transform.position.z; GameObject newObj; if (PrefabUtility.IsAnyPrefabInstanceRoot(currentSelection)) { var prefab = PrefabUtility.GetCorrespondingObjectFromSource(currentSelection); newObj = (GameObject)PrefabUtility.InstantiatePrefab(prefab, currentSelection.transform.parent); newObj.transform.position = pos; } else { newObj = Instantiate(currentSelection, pos, currentSelection.transform.rotation, currentSelection.transform.parent); } Undo.RegisterCreatedObjectUndo(newObj, "Ditribute Object"); Undo.CollapseUndoOperations(undoId); } } } } Handles.EndGUI(); }
public void DrawFooter(RampUpgradeWizard wizard) { using (var footer = new GUILayout.AreaScope(new Rect(10f, wizard.position.height - 30f, wizard.position.width - 20f, 30f), "")){ using (var bottom = new EditorGUILayout.HorizontalScope()) { // Back button using (var dis = new EditorGUI.DisabledScope(string.IsNullOrEmpty(this.previousPage))) { if (GUILayout.Button("Back", GUILayout.ExpandWidth(false))) { wizard.GoPreviousPage(); } } // Space between Back and Cancel GUILayout.FlexibleSpace(); // Cancel button if (this.canncelable) { if (GUILayout.Button("Cancel", GUILayout.ExpandWidth(false))) { if (wizard.DisplayDialog("Do you want to abort the setup?")) { wizard.GoCanncelPage(); } } } // Next & Finish button { var label = this.isEndOfWizard ? "Finish" : "Next"; if (GUILayout.Button(label, GUILayout.ExpandWidth(false))) { if (this.confirmNext && wizard.DisplayDialog("You can not UNDO the operation.\nAre you sure you want to proceed?")) { wizard.GoNextPage(); } else if (!this.confirmNext) { wizard.GoNextPage(); } } } } } // End of footer area }
private void DrawLayerModeGUI() { GUI.color = new Color(volume.YColor.r, volume.YColor.g, volume.YColor.b, 1.0f); float bwidth = 70f; using (var a = new GUILayout.AreaScope(new Rect(10f, 65f, bwidth * 2 + 10f, 85f), "", EditorStyles.textArea)) { using (var h = new GUILayout.HorizontalScope()) { GUI.color = Color.white; using (var v = new GUILayout.VerticalScope()) { if (GUILayout.Button("Pointer(Q)", GUILayout.Width(bwidth))) { HotkeyFunction("Q"); } GUI.color = volume.pointer ? Color.white : Color.gray; EditorGUILayout.LabelField("Y: " + volume.pointY, EditorStyles.textArea, GUILayout.Width(bwidth)); if (GUILayout.Button("▲(W)", GUILayout.Width(45))) { HotkeyFunction("W"); } if (GUILayout.Button("▼(S)", GUILayout.Width(45))) { HotkeyFunction("S"); } GUI.color = Color.white; } using (var v = new GUILayout.VerticalScope()) { if (GUILayout.Button("Cutter(E)", GUILayout.Width(bwidth))) { HotkeyFunction("E"); } GUI.color = volume.cuter ? Color.white : Color.gray; EditorGUILayout.LabelField("Y: " + volume.cutY, EditorStyles.textArea, GUILayout.Width(bwidth)); if (GUILayout.Button("▲(R)", GUILayout.Width(45))) { HotkeyFunction("R"); } if (GUILayout.Button("▼(F)", GUILayout.Width(45))) { HotkeyFunction("F"); } GUI.color = Color.white; } } } }
void OnGUI() { if (activo) { GUI.skin.label.alignment = TextAnchor.UpperCenter; GUI.Label(new Rect(Screen.width / 2 - 300, 50, 500, 50), "¿Estas seguro...?"); using (var areaScope = new GUILayout.AreaScope(new Rect(Screen.width / 2 - 300, 100, 500, 50))) { if (GUILayout.Button("Si")) { Reiniciar(true); } if (GUILayout.Button("No")) { aux3.SetActive(false); activo2 = false; } } } if (activo2) { GUI.skin.label.alignment = TextAnchor.UpperCenter; GUI.Label(new Rect(Screen.width / 2 - 400, 50, 500, 50), "¿Seguro?"); using (var areaScope = new GUILayout.AreaScope(new Rect(Screen.width / 2 - 300, 100, 500, 50))) { if (GUILayout.Button("Si")) { activo2 = false; } if (GUILayout.Button("No")) { activo2 = false; } } if (activo4) { GUI.Label(new Rect(Screen.width / 2 - 300, 50, 500, 50), mensaje); } } }
void OnGUI() { var s = new GUIStyle(GUI.skin.button); s.fontSize = GUI.skin.textField.fontSize; GUI.skin.button.fontSize = (int)((Screen.width * 0.02f + Screen.height * 0.02f) / 2); var r = new Rect(new Vector2(Screen.width * m_screenOffset, 50), new Vector2(Screen.width - Screen.width * m_screenOffset * 2, Screen.height - 100)); using (var a = new GUILayout.AreaScope(r, "", s)) { m_optionIndex = GUILayout.Toolbar(m_optionIndex, m_optionItems, GUILayout.Height(m_buttonOffset)); using (var scrollViewScope = new GUILayout.ScrollViewScope(scrollPostionGM)) { scrollPostionGM = scrollViewScope.scrollPosition; m_actions[m_optionIndex](); } } }
private static void OnGui() { const float fromToolsOffsetX = 400.0f; #if UNITY_2019_1_OR_NEWER const float fromStripOffsetX = 150.0f; #else const float fromStripOffsetX = 100.0f; #endif if (OnToolbarGui == null) { return; } var screenWidth = EditorGUIUtility.currentViewWidth; var toolbarRect = new Rect(0, 0, screenWidth, Style.height); //calculations known from UnityCsReference toolbarRect.xMin += fromToolsOffsetX; toolbarRect.xMax = (screenWidth - fromStripOffsetX) / 2; //additional rect styling toolbarRect.xMin += Style.spacing; toolbarRect.xMax -= Style.spacing; toolbarRect.yMin += Style.topPadding; toolbarRect.yMax -= Style.botPadding; if (toolbarRect.width <= 0) { return; } //begin drawing in calculated area using (var area = new GUILayout.AreaScope(toolbarRect)) { using (var group = new GUILayout.HorizontalScope()) { OnToolbarGui?.Invoke(); } } }
void OnGUI() { if (SyncNet.isServerOrStandAlone) { using var area = new GUILayout.AreaScope(screenRect, GetType().ToString(), "box"); GUILayout.Space(32f); var i = 0; foreach (var prefab in prefabs) { if (GUILayout.Button($"Spawn [{prefab.name}]")) { var go = Instantiate(prefab).gameObject; go.transform.position = Vector3.up * i; SyncNet.Spawn(go); } i++; } } }
///<summary> ///\~english Use this for draw window. ///</summary> void OnGUI() { bool close = false; // Process of page query if (Event.current.type == EventType.Layout) { if (!string.IsNullOrEmpty(m_pageQuery)) { // Close the window if (m_pageQuery == ExitSentinelPage) { this.Close(); return; } // Go to other page else { m_currentPage = m_pages[m_pageQuery]; } m_pageQuery = null; } } // Draw a Page if (m_currentPage != null) { // Draw GUI using (var scr = new GUILayout.AreaScope(this.PageRect)) { m_currentPage.DrawGUI(this); } m_currentPage.DrawFooter(this); } }
// Draw Material Preview void CreateMaterialPreview() { var evt = Event.current; var property = serializedObject.FindProperty("Material"); var rowRect = GUILayoutUtility.GetRect(k_MaterialRowHeight, k_MaterialRowHeight); // Need to save this rect during Repaint and use it during Layout for the AreaScope, // otherwise the AreaScope is 1 by 1 px. if (Event.current.type == EventType.Repaint) { m_MaterialPreviewRect = rowRect; } var hoverPreviewBorderStyle = GUIStyle.none; if (rowRect.Contains(evt.mousePosition)) { hoverPreviewBorderStyle = m_PreviewBorderStyle; } // Scroll wheel can cycle through modules. if (rowRect.Contains(evt.mousePosition) && evt.type == EventType.ScrollWheel) { m_TurretBuilder.CycleModules("Material", (int)evt.delta.y); m_TurretBuilder.ResetAllModulePreviewEditors(); m_TurretBuilder.RegenerateTurret(); evt.Use(); } using (var previewScope = new GUILayout.AreaScope(m_MaterialPreviewRect)) { var material = property.objectReferenceValue as Material; var currentMaterialTexture = material?.mainTexture as Texture2D; if (currentMaterialTexture != null) { m_MaterialPreviewStyle.normal.background = currentMaterialTexture; } else if (material != null) { var background = new Texture2D(1, 1); background.SetPixel(0, 0, material.color); background.Apply(); m_MaterialPreviewStyle.normal.background = background; } GUI.Box(new Rect(-30, -330, 1000, 1000), GUIContent.none, m_MaterialPreviewStyle); } using (var previewScope = new GUILayout.AreaScope(m_MaterialPreviewRect)) { // Top hover border. GUILayout.Box( GUIContent.none, hoverPreviewBorderStyle, GUILayout.Height(k_BorderWidth)); using (new GUILayout.HorizontalScope()) { GUILayout.FlexibleSpace(); using (new GUILayout.VerticalScope()) { GUILayout.FlexibleSpace(); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(property, GUILayout.Width(k_PreviewSize)); if (EditorGUI.EndChangeCheck()) { serializedObject.ApplyModifiedProperties(); m_TurretBuilder.ResetAllModulePreviewEditors(); m_TurretBuilder.RegenerateTurret(); } } GUILayout.FlexibleSpace(); } // Bottom hover border. GUILayout.Box( GUIContent.none, hoverPreviewBorderStyle, GUILayout.Height(k_BorderWidth)); } }
private void ShowCommandWindow() { GUI.SetNextControlName("commandfield"); GUI.enabled = commandData.Count > 0; command = GUI.TextField(rectCommandInput, command, guiSkin.textField); if (GUI.Button(rectCommandReturn, "Send", guiSkin.button)) { RunCommand(); } GUI.enabled = true; GUI.Box(rectCommandBackground, GUIContent.none, guiSkin.customStyles[1]); GUI.Label(rectCommandHelpBox, commandHelpText); using (var areaScope = new GUILayout.AreaScope(rectCommandArea)) { using (var scrollScope = new GUILayout.ScrollViewScope(scrollCommandPosition, guiSkin.scrollView)) { scrollScope.handleScrollWheel = true; scrollCommandPosition = scrollScope.scrollPosition; string cacheGroupName = null; using (var verticalScope = new GUILayout.VerticalScope()) { foreach (var commandElement in commandData) { if (cacheGroupName != commandElement.Value.group) { cacheGroupName = commandElement.Value.group; if (!string.IsNullOrEmpty(cacheGroupName)) { if (GUILayout.Button(cacheGroupName, guiSkin.customStyles[2])) { if (string.IsNullOrEmpty(commandDisplayingGroup) || commandDisplayingGroup != cacheGroupName) { commandDisplayingGroup = cacheGroupName; } else { commandDisplayingGroup = null; } } } else { GUILayout.Label("Etc.", guiSkin.customStyles[2]); } } if (!string.IsNullOrEmpty(commandDisplayingGroup) && commandDisplayingGroup == cacheGroupName) { if (GUILayout.Button(commandElement.Value.name, guiSkin.customStyles[3])) { command = commandElement.Key; commandHelpText = commandElement.Value.description; if (commandElement.Value.executeImmediately) { RunCommand(); } else { GUI.FocusControl("commandfield"); } } } else if (string.IsNullOrEmpty(cacheGroupName)) { if (GUILayout.Button(commandElement.Value.name, guiSkin.customStyles[3])) { command = commandElement.Key; commandHelpText = commandElement.Value.description; if (commandElement.Value.executeImmediately) { RunCommand(); } else { GUI.FocusControl("commandfield"); } } } } } } } if (GUI.GetNameOfFocusedControl() == "commandfield") { if (Event.current.isKey) { switch (Event.current.keyCode) { case KeyCode.UpArrow: GetPrevExcuteLog(); break; case KeyCode.DownArrow: GetNextExcuteLog(); break; case KeyCode.Return: case KeyCode.KeypadEnter: RunCommand(); break; } } } }
private void DrawMenuBar() { menuBar = new Rect(0, 0, position.width, menuBarHeight); using (var area = new GUILayout.AreaScope(menuBar, "", EditorStyles.toolbar)) { using (var horizon = new GUILayout.HorizontalScope()) { using (var disable = new EditorGUI.DisabledGroupScope(!CanEnterEditMode)) { using (var changed = new EditorGUI.ChangeCheckScope()) { EditMode = GUILayout.Toggle(EditMode, new GUIContent("Edit Mode"), EditorStyles.toolbarButton, GUILayout.Height(menuBarHeight)); if (changed.changed == true) { if (EditMode) { dataReader.EditStart(); } else { dataReader.EditEnd(); } } } } GUILayout.Space(5); if (GUILayout.Button(new GUIContent($"Save{(((ViewSystemDataReaderV2)dataReader).isDirty ? "*" : "")}", EditorGUIUtility.FindTexture("d_SaveAs@2x")), EditorStyles.toolbarButton, GUILayout.Width(50))) { if (isInit == false) { #if UNITY_2019_1_OR_NEWER ViewSystemLog.ShowNotification(this, new GUIContent("Editor is not Initial."), 2); #else ViewSystemLog.ShowNotification(this, new GUIContent("Editor is not Initial.")); #endif return; } if (EditorUtility.DisplayDialog("Save", "Save action will also delete all ViewElement in scene. \nDo you really want to continue?", "Yes", "No")) { if (dataReader.GetSaveData().globalSetting.UIRootScene == null) { ViewSystemLog.LogWarning("There is no UIRoot in edit, will ignore the saving of UIRoot Prefab."); } dataReader.Save(viewPageList, viewStateList); } } if (GUILayout.Button(new GUIContent("Reload", Drawer.refreshIcon, "Reload data"), EditorStyles.toolbarButton, GUILayout.Width(80))) { if (overridePopupWindow != null) { overridePopupWindow.show = false; } RefreshData(); } if (GUILayout.Button(new GUIContent("Clear Preview", "Clear all preview item"), EditorStyles.toolbarButton)) { ((ViewSystemDataReaderV2)dataReader).ClearAllViewElementInScene(); } if (GUILayout.Button(new GUIContent("Normalized", "Normalized all item (Will Delete the Canvas Root Object in Scene)"), EditorStyles.toolbarButton)) { overridePopupWindow.show = false; dataReader.Normalized(); inspector.Normalized(); } GUILayout.Space(5); using (var check = new EditorGUI.ChangeCheckScope()) { inspector.show = GUILayout.Toggle(inspector.show, new GUIContent(Drawer.inspectorIcon, "Show Inspector"), EditorStyles.toolbarButton, GUILayout.Height(menuBarHeight), GUILayout.Width(25)); if (check.changed) { inspectorContianer.parent.style.display = inspector.show ? DisplayStyle.Flex : DisplayStyle.None; } } GUILayout.Space(5); if (globalSettingWindow != null) { globalSettingWindow.show = GUILayout.Toggle(globalSettingWindow.show, new GUIContent("Global Setting", EditorGUIUtility.FindTexture("SceneViewTools")), EditorStyles.toolbarButton, GUILayout.Height(menuBarHeight)); } GUILayout.Space(5); if (viewPageOrderWindow != null) { viewPageOrderWindow.show = GUILayout.Toggle(viewPageOrderWindow.show, new GUIContent("Overlay Order", EditorGUIUtility.FindTexture("CustomSorting"), "Batch modify Overlay Pager Sorting Order"), EditorStyles.toolbarButton, GUILayout.Height(menuBarHeight)); } GUILayout.Space(5); if (GUILayout.Button(new GUIContent("Verifiers"), EditorStyles.toolbarDropDown, GUILayout.Height(menuBarHeight))) { GenericMenu genericMenu = new GenericMenu(); genericMenu.AddItem(new GUIContent("Verify GameObjects"), false, () => { viewSystemVerifier.VerifyGameObject(ViewSystemVerifier.VerifyTarget.All); } ); genericMenu.AddItem(new GUIContent("Verify Overrides"), false, () => { viewSystemVerifier.VerifyComponent(ViewSystemVerifier.VerifyTarget.Override); } ); genericMenu.AddItem(new GUIContent("Verify Events"), false, () => { viewSystemVerifier.VerifyComponent(ViewSystemVerifier.VerifyTarget.Event); } ); genericMenu.AddItem(new GUIContent("Verify Pages and States"), false, () => { viewSystemVerifier.VerifyPagesAndStates(); } ); genericMenu.ShowAsContext(); } using (var check = new EditorGUI.ChangeCheckScope()) { search = EditorGUILayout.TextField(search, new GUIStyle("SearchTextField")); } GUILayout.FlexibleSpace(); GUILayout.Label(new GUIContent(Drawer.zoomIcon, "Zoom"), GUIStyle.none); zoomScale = EditorGUILayout.Slider(zoomScale, zoomScaleMinMax.x, zoomScaleMinMax.y, GUILayout.Width(120)); if (GUILayout.Button(new GUIContent(EditorGUIUtility.FindTexture("AvatarCompass"), "Reset viewport to (0,0)"), EditorStyles.toolbarButton, GUILayout.Width(30))) { viewPortScroll = Vector2.zero; } if (GUILayout.Button(new GUIContent(Drawer.bakeScritpIcon, "Bake ViewPage and ViewState to script"), EditorStyles.toolbarButton, GUILayout.Width(50))) { ViewSystemScriptBaker.BakeAllViewPageName( viewPageList.Select(m => m.viewPage).ToList(), viewStateList.Select(m => m.viewState).ToList(), saveData.globalSetting.breakPoints.ToList()); } if (GUILayout.Button("Options", EditorStyles.toolbarDropDown)) { UnityEditor.PopupWindow.Show(popupBtnRect, new EditorPopupSetting()); } if (Event.current.type == EventType.Repaint) { popupBtnRect = GUILayoutUtility.GetLastRect(); } } } }
void OnWindowGUI(int id) { GUI.skin = HighLogic.Skin; var historian = Historian.Instance; var configuration = historian.GetConfiguration(); // column one using (var columnOne = new GUILayout.AreaScope(new Rect(15, 20, 380, 550))) { using (var col = new GUILayout.VerticalScope()) { GUILayout.Space(20); historian.Suppressed = GUILayout.Toggle(historian.Suppressed, "Suppressed"); historian.AlwaysActive = GUILayout.Toggle(historian.AlwaysActive, "Always Active"); historian.AutoHideUI = GUILayout.Toggle(historian.AutoHideUI, "Auto hide UI"); configuration.AutoHideUI = historian.AutoHideUI; configuration.PersistentConfigurationWindow = GUILayout.Toggle(configuration.PersistentConfigurationWindow, "Always Display Configuration Window"); enableLauncherButton = GUILayout.Toggle(enableLauncherButton, "Use Stock Launcher"); enableToolberButton = GUILayout.Toggle(enableToolberButton, "Use Blizzy's Toolbar"); GUILayout.Space(10); using (var layout = new GUILayout.HorizontalScope()) { var rightClickOptionsCount = 4; //GUILayout.Space(40); GUILayout.Label("Right click action"); GUILayout.Space(10); if (GUILayout.Button(previousButtonTexture, GUILayout.Width(20), GUILayout.Height(GUI.skin.label.lineHeight))) { configuration.RightClickAction = (RightClickAction)Mathf.Clamp((int)configuration.RightClickAction - 1, 0, rightClickOptionsCount - 1); } else if (GUILayout.Button(nextButtonTexture, GUILayout.Width(20), GUILayout.Height(GUI.skin.label.lineHeight))) { configuration.RightClickAction = (RightClickAction)Mathf.Clamp((int)configuration.RightClickAction + 1, 0, rightClickOptionsCount - 1); } GUILayout.Space(5); GUILayout.Label(configuration.RightClickAction.ToString(), GUI.skin.textArea, GUILayout.ExpandWidth(true)); } ManageButtons(); GUILayout.Space(10); using (var layout = new GUILayout.HorizontalScope()) { GUILayout.Label("Layout"); GUILayout.Space(10); var layouts = historian.GetLayoutNames(); if (GUILayout.Button(previousButtonTexture, GUILayout.Width(20), GUILayout.Height(GUI.skin.label.lineHeight))) { historian.CurrentLayoutIndex = Mathf.Clamp(historian.CurrentLayoutIndex - 1, 0, layouts.Length - 1); } else if (GUILayout.Button(nextButtonTexture, GUILayout.Width(20), GUILayout.Height(GUI.skin.label.lineHeight))) { historian.CurrentLayoutIndex = Mathf.Clamp(historian.CurrentLayoutIndex + 1, 0, layouts.Length - 1); } GUILayout.Space(5); GUILayout.Label(historian.GetCurrentLayoutName(), GUI.skin.textArea, GUILayout.ExpandWidth(true)); } GUILayout.Space(10); using (var customHead = new GUILayout.HorizontalScope()) { GUILayout.Label("Custom Text:"); GUILayout.FlexibleSpace(); configuration.PersistentCustomText = GUILayout.Toggle(configuration.PersistentCustomText, "Persistent", GUILayout.Width(120)); } configuration.CustomText = GUILayout.TextArea(configuration.CustomText, GUI.skin.textArea, GUILayout.Height(60)); GUILayout.Space(10); using (var spaceCentre = new GUILayout.HorizontalScope()) { GUILayout.Label("Default Space Center Name:"); GUILayout.FlexibleSpace(); configuration.DefaultSpaceCenterName = GUILayout.TextField(configuration.DefaultSpaceCenterName, GUI.skin.textArea, GUILayout.Width(150)); } GUILayout.Space(10); GUILayout.Label($"Time to remember action key press: {configuration.TimeToRememberLastAction} ms"); configuration.TimeToRememberLastAction = (int)GUILayout.HorizontalSlider(configuration.TimeToRememberLastAction, 250, 10000, GUILayout.ExpandWidth(true)); } } // column two using (var columnTwo = new GUILayout.AreaScope(new Rect(410, 20, 220, 500))) { using (var col = new GUILayout.VerticalScope()) { GUILayout.Space(20); GUILayout.Label("Kerbin calendar day names:"); for (int i = 0; i < configuration.KerbinDayNames.Length; i++) { using (var item = new GUILayout.HorizontalScope()) { GUILayout.Label($"{i + 1}:"); GUILayout.FlexibleSpace(); configuration.KerbinDayNames[i] = GUILayout.TextField(configuration.KerbinDayNames[i], GUI.skin.textArea, GUILayout.Width(190f)); } } GUILayout.Space(50); GUILayout.Label("Default empty crew slot labels:"); GUILayout.Space(10); using (var noCrewLabel = new GUILayout.HorizontalScope()) { GUILayout.Label("Crewed:"); GUILayout.FlexibleSpace(); configuration.DefaultNoCrewLabel = GUILayout.TextField(configuration.DefaultNoCrewLabel, GUI.skin.textArea, GUILayout.Width(120)); } using (var noCrewLabel = new GUILayout.HorizontalScope()) { GUILayout.Label("Uncrewed:"); GUILayout.FlexibleSpace(); configuration.DefaultUnmannedLabel = GUILayout.TextField(configuration.DefaultUnmannedLabel, GUI.skin.textArea, GUILayout.Width(120)); } } } // column three using (var columnThree = new GUILayout.AreaScope(new Rect(660, 20, 220, 480))) { using (var col = new GUILayout.VerticalScope()) { GUILayout.Space(20); GUILayout.Label("Kerbin calendar month names:"); for (int i = 0; i < configuration.KerbinMonthNames.Length; i++) { using (var item = new GUILayout.HorizontalScope()) { GUILayout.Label($"{i + 1}:"); GUILayout.FlexibleSpace(); configuration.KerbinMonthNames[i] = GUILayout.TextField(configuration.KerbinMonthNames[i], GUI.skin.textArea, GUILayout.Width(190f)); } } } } // bottom bar using (var buttonBar = new GUILayout.AreaScope(new Rect(5, 525, 890, 30))) { using (var layout = new GUILayout.HorizontalScope()) { GUILayout.FlexibleSpace(); if (GUILayout.Button("Load", GUILayout.Width(100.0f))) { historian.Reload(); } if (GUILayout.Button("Save", GUILayout.Width(100.0f))) { configuration.Layout = historian.GetCurrentLayoutName(); configuration.EnableLauncherButton = enableLauncherButton; configuration.EnableToolbarButton = enableToolberButton; historian.SetConfiguration(configuration); if (!configuration.PersistentConfigurationWindow) { Toggle(); } } GUILayout.Space(20); // GUILayout.FlexibleSpace(); } } GUI.DragWindow(); }
private void OnGUI() { var position = new Vector2(_position.x, _position.y); var size = new Vector2(240, 9999); using (var _ = new GUILayout.AreaScope(new Rect(position, size))) { GUI.Box(new Rect(Vector2.zero, size), ""); switch (_client.status) { case PlanetaMatchMakerClient.Status.Disconnected: GUILayout.Label("Player Name"); _playerName = GUILayout.TextField(_playerName); if (GUILayout.Button("Connect")) { _client.Connect(_playerName); } if (_isJoinedRoom) { GUILayout.Label($"Joined Room Host: {_joinedRoomHost}"); } break; case PlanetaMatchMakerClient.Status.Connecting: GUILayout.Label($"Connecting.."); break; case PlanetaMatchMakerClient.Status.SearchingRoom: // Display room group list GUILayout.Label($"Player Full Name: {_client.playerFullName.GenerateFullName()}"); GUILayout.Label("===Room Group List==="); for (var i = 0; i < _client.roomGroupInfoList.Count; ++i) { GUILayout.Label($"{i}: {_client.roomGroupInfoList[i].name}"); } GUILayout.Label("Selected Room Group Index"); var roomGroupIndexStr = GUILayout.TextField(_client.roomGroupIndex.ToString()); byte.TryParse(roomGroupIndexStr, out var roomGroupIndex); if (_client.roomGroupIndex != roomGroupIndex) { _client.roomGroupIndex = roomGroupIndex; RequestRoomList(); } // Display room list GUILayout.Label($"===Room List Setting==="); _searchPublicRoom = GUILayout.Toggle(_searchPublicRoom, "Search Public"); _searchPrivateRoom = GUILayout.Toggle(_searchPrivateRoom, "Search Private"); _searchOpenRoom = GUILayout.Toggle(_searchOpenRoom, "Search Open"); _searchClosedRoom = GUILayout.Toggle(_searchClosedRoom, "Search Closed"); GUILayout.Label("Search Name"); _roomSearchName = GUILayout.TextField(_roomSearchName); GUILayout.Label("Search Tag"); ushort.TryParse(GUILayout.TextField(_roomSearchTag.ToString()), out _roomSearchTag); GUILayout.Label($"===Room List in Group {_client.roomGroupIndex}==="); GUILayout.Label($"Push button to join."); foreach (var room in _roomList) { if (GUILayout.Button( $"{room.hostPlayerFullName}: {room.roomId}({room.currentPlayerCount}/{room.maxPlayerCount})\n[{room.settingFlags}]\n@{room.createDatetime}") ) { JoinRoom(room.roomId); } } GUILayout.Label($"===Selected or Create Room Info==="); GUILayout.Label("Room Password"); _roomPassword = GUILayout.TextField(_roomPassword); GUILayout.Label("Max Player Count"); byte.TryParse(GUILayout.TextField(_roomMaxPlayerCount.ToString()), out _roomMaxPlayerCount); GUILayout.Label($"===Operations==="); if (GUILayout.Button("Create")) { HostRoom(); } if (GUILayout.Button("CreateWithPM")) { HostRoomWithCreatingPortMapping(); } if (GUILayout.Button("Disconnect")) { Close(); } break; case PlanetaMatchMakerClient.Status.StartingHostingRoom: GUILayout.Label($"Creating hosting room..."); break; case PlanetaMatchMakerClient.Status.HostingRoom: GUILayout.Label($"Player Full Name: {_client.playerFullName.GenerateFullName()}"); GUILayout.Label("Current Player Count"); byte.TryParse(GUILayout.TextField(_roomCurrentPlayerCount.ToString()), out _roomCurrentPlayerCount); _openRoom = GUILayout.Toggle(_openRoom, "Open Room"); if (GUILayout.Button("Update")) { UpdateHostingRoomStatus(); } if (GUILayout.Button("Remove")) { RemoveHostingRoom(); } if (GUILayout.Button("Disconnect")) { Close(); } break; case PlanetaMatchMakerClient.Status.FinishingHostingRoom: GUILayout.Label($"Removing hosting room..."); break; case PlanetaMatchMakerClient.Status.StartingJoiningRoom: GUILayout.Label($"Joining to room..."); break; default: throw new ArgumentOutOfRangeException(); } if (_isErrorOccured) { GUILayout.Label(_errorMessage); } } }
public void OnGUI() { using (var area1 = new GUILayout.AreaScope(new Rect(0, 0, 320, 320))) { } }
void OnWindowGUI(int id) { GUI.skin = HighLogic.Skin; var historian = Historian.Instance; var configuration = historian.GetConfiguration(); // column one using (var columnOne = new GUILayout.AreaScope(new Rect(15, 20, 380, 550))) { using (var col = new GUILayout.VerticalScope()) { GUILayout.Space(20); historian.Suppressed = GUILayout.Toggle(historian.Suppressed, Localizer.GetStringByTag("#Historian_Suppressed")); historian.AlwaysActive = GUILayout.Toggle(historian.AlwaysActive, Localizer.GetStringByTag("#Historian_AlwaysActive")); historian.AutoHideUI = GUILayout.Toggle(historian.AutoHideUI, Localizer.GetStringByTag("#Historian_AutoHideUI")); configuration.AutoHideUI = historian.AutoHideUI; configuration.PersistentConfigurationWindow = GUILayout.Toggle(configuration.PersistentConfigurationWindow, Localizer.GetStringByTag("#Historian_AlwaysShowConfigWindow")); enableLauncherButton = GUILayout.Toggle(enableLauncherButton, Localizer.GetStringByTag("#Historian_UseAppLauncher")); enableToolberButton = GUILayout.Toggle(enableToolberButton, Localizer.GetStringByTag("#Historian_UseToolbar")); GUILayout.Space(10); using (var layout = new GUILayout.HorizontalScope()) { var rightClickOptionsCount = 4; //GUILayout.Space(40); GUILayout.Label(Localizer.GetStringByTag("#Historian_RightClickAction")); GUILayout.Space(10); if (GUILayout.Button(previousButtonTexture, GUILayout.Width(20), GUILayout.Height(GUI.skin.label.lineHeight))) { configuration.RightClickAction = (RightClickAction)Mathf.Clamp((int)configuration.RightClickAction - 1, 0, rightClickOptionsCount - 1); } else if (GUILayout.Button(nextButtonTexture, GUILayout.Width(20), GUILayout.Height(GUI.skin.label.lineHeight))) { configuration.RightClickAction = (RightClickAction)Mathf.Clamp((int)configuration.RightClickAction + 1, 0, rightClickOptionsCount - 1); } GUILayout.Space(5); GUILayout.Label(configuration.RightClickAction.ToString(), GUI.skin.textArea, GUILayout.ExpandWidth(true)); } ManageButtons(); GUILayout.Space(10); using (var layout = new GUILayout.HorizontalScope()) { GUILayout.Label(Localizer.GetStringByTag("#Historian_Layout")); GUILayout.Space(10); var layouts = historian.GetLayoutNames(); if (GUILayout.Button(previousButtonTexture, GUILayout.Width(20), GUILayout.Height(GUI.skin.label.lineHeight))) { historian.CurrentLayoutIndex = Mathf.Clamp(historian.CurrentLayoutIndex - 1, 0, layouts.Length - 1); } else if (GUILayout.Button(nextButtonTexture, GUILayout.Width(20), GUILayout.Height(GUI.skin.label.lineHeight))) { historian.CurrentLayoutIndex = Mathf.Clamp(historian.CurrentLayoutIndex + 1, 0, layouts.Length - 1); } GUILayout.Space(5); GUILayout.Label(historian.GetCurrentLayoutName(), GUI.skin.textArea, GUILayout.ExpandWidth(true)); } GUILayout.Space(10); using (var customHead = new GUILayout.HorizontalScope()) { GUILayout.Label(Localizer.GetStringByTag("#Historian_CustomText")); GUILayout.FlexibleSpace(); configuration.PersistentCustomText = GUILayout.Toggle(configuration.PersistentCustomText, Localizer.GetStringByTag("#Historian_Persistent"), GUILayout.Width(120)); } configuration.CustomText = GUILayout.TextArea(configuration.CustomText, GUI.skin.textArea, GUILayout.Height(60)); GUILayout.Space(10); using (var spaceCentre = new GUILayout.HorizontalScope()) { GUILayout.Label(Localizer.GetStringByTag("#Historian_DefaultSpaceCenterLabel")); GUILayout.FlexibleSpace(); configuration.DefaultSpaceCenterName = GUILayout.TextField(configuration.DefaultSpaceCenterName, GUI.skin.textArea, GUILayout.Width(150)); } GUILayout.Space(10); GUILayout.Label($"{Localizer.GetStringByTag("#Historian_LastActionTime")}: {configuration.TimeToRememberLastAction} ms"); configuration.TimeToRememberLastAction = (int)GUILayout.HorizontalSlider(configuration.TimeToRememberLastAction, 250, 10000, GUILayout.ExpandWidth(true)); } } // column two using (var columnTwo = new GUILayout.AreaScope(new Rect(410, 20, 220, 500))) { using (var col = new GUILayout.VerticalScope()) { GUILayout.Space(20); GUILayout.Label(Localizer.GetStringByTag("#Historian_DayNames")); for (int i = 0; i < configuration.KerbinDayNames.Length; i++) { using (var item = new GUILayout.HorizontalScope()) { GUILayout.Label($"{i + 1}:"); GUILayout.FlexibleSpace(); configuration.KerbinDayNames[i] = GUILayout.TextField(configuration.KerbinDayNames[i], GUI.skin.textArea, GUILayout.Width(190f)); } } GUILayout.Space(50); GUILayout.Label(Localizer.GetStringByTag("#Historian_DefaultEmptyCrewSlot")); GUILayout.Space(10); using (var noCrewLabel = new GUILayout.HorizontalScope()) { GUILayout.Label(Localizer.GetStringByTag("#Historian_CrewedLabel")); GUILayout.FlexibleSpace(); configuration.DefaultNoCrewLabel = GUILayout.TextField(configuration.DefaultNoCrewLabel, GUI.skin.textArea, GUILayout.Width(120)); } using (var noCrewLabel = new GUILayout.HorizontalScope()) { GUILayout.Label(Localizer.GetStringByTag("#Historian_UncrewedLabel")); GUILayout.FlexibleSpace(); configuration.DefaultUnmannedLabel = GUILayout.TextField(configuration.DefaultUnmannedLabel, GUI.skin.textArea, GUILayout.Width(120)); } } } // column three using (var columnThree = new GUILayout.AreaScope(new Rect(660, 20, 220, 480))) { using (var col = new GUILayout.VerticalScope()) { GUILayout.Space(20); GUILayout.Label(Localizer.GetStringByTag("#Historian_MonthNames")); for (int i = 0; i < configuration.KerbinMonthNames.Length; i++) { using (var item = new GUILayout.HorizontalScope()) { GUILayout.Label($"{i + 1}:"); GUILayout.FlexibleSpace(); configuration.KerbinMonthNames[i] = GUILayout.TextField(configuration.KerbinMonthNames[i], GUI.skin.textArea, GUILayout.Width(190f)); } } } } // bottom bar using (var buttonBar = new GUILayout.AreaScope(new Rect(5, 525, 890, 30))) { using (var layout = new GUILayout.HorizontalScope()) { GUILayout.FlexibleSpace(); if (GUILayout.Button(Localizer.GetStringByTag("#autoLOC_900539"), GUILayout.Width(100.0f))) // #autoLOC_900539 = Load { historian.Reload(); } if (GUILayout.Button(Localizer.GetStringByTag("#autoLOC_174778"), GUILayout.Width(100.0f))) // #autoLOC_174778 = Save { configuration.Layout = historian.GetCurrentLayoutName(); configuration.EnableLauncherButton = enableLauncherButton; configuration.EnableToolbarButton = enableToolberButton; historian.SetConfiguration(configuration); if (!configuration.PersistentConfigurationWindow) { Toggle(); } if (!String.IsNullOrEmpty(configuration.CustomText)) { configuration.TokenizedCustomText = Parser.GetTokens(configuration.CustomText); } } GUILayout.Space(20); // GUILayout.FlexibleSpace(); } } GUI.DragWindow(); }