public void Draw() { if (display) { GUI.skin = HighLogic.Skin; windowPosition = GUILayout.Window(ConfigHandler.Instance.LayoutWindow, windowPosition, DrawWindow, "Catalog GUI Layout", GUILayout.ExpandHeight(true)); } }
private void RenderTestInfo() { var ctrlId = GUIUtility.GetControlID(FocusType.Passive); var rect = GUILayoutUtility.GetLastRect(); if (m_Settings.horizontalSplit) { rect.y = rect.height + rect.y - 1; rect.height = 3; } else { rect.x = rect.width + rect.x - 1; rect.width = 3; } EditorGUIUtility.AddCursorRect(rect, m_Settings.horizontalSplit ? MouseCursor.ResizeVertical : MouseCursor.ResizeHorizontal); var e = Event.current; switch (e.type) { case EventType.MouseDown: if (GUIUtility.hotControl == 0 && rect.Contains(e.mousePosition)) { GUIUtility.hotControl = ctrlId; } break; case EventType.MouseDrag: if (GUIUtility.hotControl == ctrlId) { m_HorizontalSplitBarPosition -= e.delta.y; if (m_HorizontalSplitBarPosition < 20) { m_HorizontalSplitBarPosition = 20; } m_VerticalSplitBarPosition -= e.delta.x; if (m_VerticalSplitBarPosition < 20) { m_VerticalSplitBarPosition = 20; } Repaint(); } break; case EventType.MouseUp: if (GUIUtility.hotControl == ctrlId) { GUIUtility.hotControl = 0; } break; } m_TestInfoScroll = EditorGUILayout.BeginScrollView(m_TestInfoScroll, m_Settings.horizontalSplit ? GUILayout.MinHeight(m_HorizontalSplitBarPosition) : GUILayout.Width(m_VerticalSplitBarPosition)); var text = ""; if (m_SelectedLines.Any()) { text = m_SelectedLines.First().GetResultText(); } var resultTextSize = Styles.info.CalcSize(new GUIContent(text)); EditorGUILayout.SelectableLabel(text, Styles.info, GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true), GUILayout.MinWidth(resultTextSize.x), GUILayout.MinHeight(resultTextSize.y)); EditorGUILayout.EndScrollView(); }
private void DrawAdditionalOptions() { additionalScrollPos = GUILayout.BeginScrollView(additionalScrollPos, GUILayout.ExpandHeight(true)); GUILayout.Space(4f); GUILayout.BeginVertical(GUILayout.ExpandHeight(true)); GUILayout.Box("User Interface Settings", GUILayout.ExpandWidth(true)); GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); GUILayout.Label("Globally Enable Animation", GUILayout.ExpandWidth(true)); Settings.Instance.FlaskAnimationEnabled = AudibleToggle(Settings.Instance.FlaskAnimationEnabled, string.Empty, null, new[] { GUILayout.ExpandWidth(false) }); if (!Settings.Instance.FlaskAnimationEnabled && scienceAlert.Button.IsAnimating) { scienceAlert.Button.SetLit(); } GUILayout.EndHorizontal(); Settings.Instance.ShowReportValue = AudibleToggle(Settings.Instance.ShowReportValue, "Display Report Value"); Settings.Instance.DisplayCurrentBiome = AudibleToggle(Settings.Instance.DisplayCurrentBiome, "Display Biome in Experiment List"); Settings.Instance.EvaReportOnTop = AudibleToggle(Settings.Instance.EvaReportOnTop, "List EVA Report first"); GUILayout.Label("Window Opacity"); GUILayout.BeginHorizontal(); GUILayout.Label("Less", miniLabelLeft); GUILayout.FlexibleSpace(); GUILayout.Label("More", miniLabelRight); GUILayout.EndHorizontal(); Settings.Instance.WindowOpacity = (int)GUILayout.HorizontalSlider(Settings.Instance.WindowOpacity, 0f, 255f, GUILayout.ExpandWidth(true), GUILayout.MaxHeight(16f)); GUILayout.Space(8f); GUILayout.Box("Third-party Integration Options", GUILayout.ExpandWidth(true)); GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); Settings.ScanInterface scanInterfaceType = Settings.Instance.ScanInterfaceType; Color color = GUI.color; if (!SCANsatInterface.IsAvailable()) { GUI.color = Color.red; } bool flag = AudibleToggle(Settings.Instance.ScanInterfaceType == Settings.ScanInterface.ScanSat, "Enable SCANsat integration", null, new[] { GUILayout.ExpandWidth(true) }); GUI.color = color; if (flag && scanInterfaceType != Settings.ScanInterface.ScanSat && !SCANsatInterface.IsAvailable()) { PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), "SCANsat Not Found", "SCANsat was not found. You must install SCANsat to use this feature.", "", "Okay", false, HighLogic.UISkin); flag = false; } Settings.Instance.ScanInterfaceType = flag ? Settings.ScanInterface.ScanSat : Settings.ScanInterface.None; scienceAlert.ScanInterfaceType = Settings.Instance.ScanInterfaceType; GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); //Settings.ToolbarInterface toolbarInterfaceType = Settings.Instance.ToolbarInterfaceType; Color color2 = GUI.color; if (!ToolbarManager.ToolbarAvailable) { GUI.color = Color.red; } //bool flag2 = AudibleToggle(Settings.Instance.ToolbarInterfaceType == Settings.ToolbarInterface.BlizzyToolbar, "Use Blizzy toolbar"); GUI.color = color2; //if (flag2 && toolbarInterfaceType != Settings.ToolbarInterface.BlizzyToolbar && !ToolbarManager.ToolbarAvailable) //{ // PopupDialog.SpawnPopupDialog("Blizzy Toolbar Not Found", // "Blizzy's toolbar was not found. You must install Blizzy's toolbar to use this feature.", // "Okay", false, Settings.Skin); //??? // flag2 = false; //} //Settings.Instance.ToolbarInterfaceType = (flag2 ? Settings.ToolbarInterface.BlizzyToolbar : Settings.ToolbarInterface.ApplicationLauncher); if (scienceAlert.ToolbarType != Settings.Instance.ToolbarInterfaceType) { scienceAlert.ToolbarType = Settings.Instance.ToolbarInterfaceType; } GUILayout.EndHorizontal(); GUILayout.Box("Crewed Vessel Settings", GUILayout.ExpandWidth(true)); bool checkSurfaceSampleNotEva = Settings.Instance.CheckSurfaceSampleNotEva; Settings.Instance.CheckSurfaceSampleNotEva = AudibleToggle(checkSurfaceSampleNotEva, "Track surface sample in vessel"); if (checkSurfaceSampleNotEva != Settings.Instance.CheckSurfaceSampleNotEva) { manager.RebuildObserverList(); } GUILayout.EndVertical(); GUI.skin = Settings.Skin; GUILayout.EndScrollView(); }
public override void OnGUI() { base.OnGUI(); using (new EditorGUILayout.HorizontalScope()) { using (new EditorGUILayout.VerticalScope()) { using (new EditorGUILayout.VerticalScope(HeEditorStyles.panel)) { using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.LabelField("Compare Snapshot (A) with (B)", EditorStyles.boldLabel); if (m_CompareSearchField.OnToolbarGUI()) { m_CompareControl.Search(m_CompareSearchField.text); } } GUILayout.Space(2); using (new EditorGUILayout.HorizontalScope()) { if (GUILayout.Button(new GUIContent("Swap", "Swap snapshot A <> B"), GUILayout.Width(64), GUILayout.ExpandHeight(true))) { SwapSnapshots(); } using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox)) { using (new EditorGUILayout.HorizontalScope()) { GUILayout.Label("(A)", GUILayout.Width(24)); if (!string.IsNullOrEmpty(window.snapshotPath)) { if (window.snapshotPath.EndsWith(".heap", System.StringComparison.OrdinalIgnoreCase)) { GUILayout.Label(System.IO.Path.GetFileName(window.snapshotPath)); } else { GUILayout.Label(window.snapshotPath); } } GUILayout.FlexibleSpace(); } using (new EditorGUILayout.HorizontalScope()) { GUILayout.Label("(B)", GUILayout.Width(24)); if (!string.IsNullOrEmpty(m_SnapshotBPath)) { if (m_SnapshotBPath.EndsWith(".heap", System.StringComparison.OrdinalIgnoreCase)) { GUILayout.Label(System.IO.Path.GetFileName(m_SnapshotBPath)); } else { GUILayout.Label(m_SnapshotBPath); } } if (GUILayout.Button(new GUIContent("Load...", "Load snapshot (B)"), GUILayout.Width(64))) { var menu = new GenericMenu(); menu.AddItem(new GUIContent("Browse..."), false, delegate() { var path = EditorUtility.OpenFilePanel("Load", "", "heap"); if (!string.IsNullOrEmpty(path)) { HeMruFiles.AddPath(path); LoadSnapshotB(path); } }); menu.AddSeparator(""); for (int n = 0; n < HeMruFiles.count; ++n) { var path = HeMruFiles.GetPath(n); if (string.IsNullOrEmpty(path)) { continue; } if (!System.IO.File.Exists(path)) { continue; } menu.AddItem(new GUIContent((n + 1) + " " + path.Replace('/', '\\')), false, delegate(System.Object obj) { var p = obj as string; HeMruFiles.AddPath(p); LoadSnapshotB(p); }, path); } menu.ShowAsContext(); } GUILayout.FlexibleSpace(); } GUILayout.Space(2); } } GUILayout.Space(2); m_CompareControl.OnGUI(); } } } if (m_Job != null) { window.SetBusy(m_Job.stateString); Repaint(); } }
private void Draw() { GUIStyle selectedStyle = new GUIStyle(GUI.skin.label); selectedStyle.fontStyle = FontStyle.Bold; if (GUILayout.Button("Refresh")) { LoadData(); CreateTestListTable(); if (m_resultsData == null) { return; } if (m_resultsData.Results == null) { return; } if (m_resultsData.Results.Any(result => result.Name == m_selectedTest)) { SelectTest(m_selectedTest); } else { SelectTest(0); } } if (m_resultsData == null) { return; } if (m_resultsData.Results.Count <= 0) { GUILayout.Label("No performance test data found."); } else { m_showTests = BoldFoldout(m_showTests, "Test View"); if (m_showTests) { if (m_testListTable != null) { Rect r = GUILayoutUtility.GetRect(position.width, s_windowHeight / 4, GUI.skin.box, GUILayout.ExpandWidth(true)); m_testListTable.OnGUI(r); } } if (!string.IsNullOrEmpty(m_selectedTest)) { var profileDataFile = Path.Combine(Application.persistentDataPath, Utils.RemoveIllegalCharacters(m_selectedTest) + ".raw"); if (File.Exists(profileDataFile)) { if (GUILayout.Button(string.Format("Load profiler data for test: {0}", m_selectedTest))) { ProfilerDriver.LoadProfile(profileDataFile, false); } } } m_showSamples = BoldFoldout(m_showSamples, "Sample Group View"); if (m_showSamples) { SetColumnSizes(50, 50, 50, 50); EditorGUILayout.BeginVertical(); m_sampleGroupScroll = EditorGUILayout.BeginScrollView(m_sampleGroupScroll, false, true); //, false, false, GUIStyle.none, GUI.skin.verticalScrollbar, GUI.skin.window); int dataIndex = 0; foreach (var result in m_resultsData.Results) { if (result.Name != m_selectedTest) { dataIndex += result.SampleGroups.Count; continue; } foreach (var sampleGroup in result.SampleGroups) { var data = m_sampleGroupAdditionalData[dataIndex]; dataIndex++; float min = data.min; float lowerQuartile = data.lowerQuartile; float median = data.median; float upperQuartile = data.upperQuartile; float max = data.max; float graphMin = min > 0.0f ? 0.0f : min; EditorGUILayout.BeginVertical(GUI.skin.box, GUILayout.Width(position.width - GUI.skin.verticalScrollbar.fixedWidth - (GUI.skin.box.padding.horizontal + GUI.skin.box.margin.horizontal)), GUILayout.ExpandHeight(false)); EditorGUILayout.LabelField(sampleGroup.Name, m_boldStyle); EditorGUILayout.LabelField("Sample Unit: " + sampleGroup.Unit.ToString()); EditorGUILayout.BeginHorizontal(GUILayout.Height(100), GUILayout.ExpandHeight(false)); EditorGUILayout.BeginVertical(GUILayout.Width(100), GUILayout.ExpandHeight(true)); Draw2Column("Max", max); GUILayout.FlexibleSpace(); Color oldColor = GUI.contentColor; if (median < 0.01f) { GUI.contentColor = m_colorWarningText; } else { GUI.contentColor = m_colorMedianText; } Draw2Column("Median", median); GUI.contentColor = oldColor; //Draw2Column("SD", (float)sampleGroup.StandardDeviation); //Draw2Column("P", (float)sampleGroup.PercentileValue); GUILayout.FlexibleSpace(); Draw2Column("Min", min); EditorGUILayout.EndVertical(); DrawBarGraph(position.width - 200, 100, sampleGroup.Samples, graphMin, max, median); DrawBoxAndWhiskerPlot(50, 100, min, lowerQuartile, median, upperQuartile, max, min, max, (float)sampleGroup.StandardDeviation, m_colorWhite, m_colorBoxAndWhiskerBackground); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); } } EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); } } }
public void DrawLayout() { CacheDisplayedPanels(); if (!show) { return; } var position = GUILayoutUtility.GetRect(GUIContent.none, GUIStyle.none, GUILayout.Width(GetWidth()), GUILayout.ExpandHeight(true)); if (!e.IsLayout && !Event.current.ShouldSkip()) { OnGUI(position); } }
public void DrawModule(T component, int index) { var module = component as UnityEngine.Component; if (module != null) { EditorGUILayout.BeginHorizontal(Style.moduleTitleStyle); var behaviour = module as UnityEngine.Behaviour; if (behaviour != null && canDisableModules) { behaviour.enabled = GUILayout.Toggle(behaviour.enabled, "", Style.moduleToggleStyle); } GUILayout.Label(" " + module.GetType().Name, Style.moduleTitleLabelStyle); if (canReorderModules) { Rect rect = GUILayoutUtility.GetRect(EditorGUIUtility.singleLineHeight, EditorGUIUtility.singleLineHeight, EditorGUIUtility.singleLineHeight, EditorGUIUtility.singleLineHeight, GUILayout.ExpandHeight(false)); rect.width = EditorGUIUtility.singleLineHeight; rect.y -= 2f; rect.x = EditorGUIUtility.currentViewWidth - 80f; if (GUI.Button(rect, "", Style.moveModuleUpButtonStyle)) { // Up UnityEditorInternal.ComponentUtility.MoveComponentUp(module); UpdateList(); } rect.x += EditorGUIUtility.singleLineHeight; if (GUI.Button(rect, "", Style.moveModuleDownButtonStyle)) { // Down UnityEditorInternal.ComponentUtility.MoveComponentDown(module); UpdateList(); } } if (GUILayout.Button("", Style.removeModuleButtonStyle, GUILayout.Width(30f), GUILayout.Height(EditorGUIUtility.singleLineHeight))) { UnityEngine.Object.DestroyImmediate(module); UpdateList(); return; } EditorGUILayout.EndHorizontal(); if ((behaviour != null && behaviour.enabled) || behaviour == null) { drawModuleEditor(module); } } }
// 绘制行为图标 // @actionData:行为数据 private void DrawActionItem(SkillActionData actionData) { if (CheckActionIsValid(actionData)) { if (actionData.tA == 1) { GUI.backgroundColor = new Color32(255, 175, 0, 255); } else { GUI.backgroundColor = Color.green; } } else { GUI.backgroundColor = Color.red; } GUILayout.BeginVertical(new GUIStyle(EditorStyles.textField), GUILayout.Width(MENU_WIDTH - 20), GUILayout.ExpandHeight(true)); GUI.backgroundColor = m_defaultBgClr; GUILayout.BeginHorizontal(); GUILayout.Label("行为id:", GUILayout.Width(75)); actionData.i = (int)EditorGUILayout.IntField(actionData.i, GUILayout.Width(100)); //GUILayout.FlexibleSpace(); if (GUILayout.Button("-", GUILayout.Width(20))) { List <SkillActionData> listAction = new List <SkillActionData>(m_skillData.aA); listAction.Remove(actionData); m_skillData.aA = listAction.ToArray(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("行为类型:", GUILayout.Width(75)); actionData.a = (int)EditorGUILayout.Popup(actionData.a, ARR_ACTION_TYPE_NAME, GUILayout.Width(100)); //GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); bool isTrigger = actionData.tA == 1; if (!isTrigger) { GUILayout.Label("行为播放时间:", GUILayout.Width(75)); actionData.t = EditorGUILayout.FloatField(actionData.t, GUILayout.Width(100)); } GUILayout.Label("触发行为:", GUILayout.Width(75)); isTrigger = EditorGUILayout.Toggle(isTrigger, GUILayout.Width(40)); actionData.tA = isTrigger ? 1 : 0; GUILayout.EndHorizontal(); if (actionData.a == (int)SkillActionType.PLAY_EFFECT || actionData.a == (int)SkillActionType.PLAY_EFFECT_SELF) // 播放特效 { GUILayout.BeginHorizontal(); GUILayout.Label("特效ID:", GUILayout.Width(75)); actionData.e1 = EditorGUILayout.IntField(actionData.e1, GUILayout.Width(100)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("坐标X:", GUILayout.Width(75)); actionData.x = EditorGUILayout.IntField(actionData.x, GUILayout.Width(100)); GUILayout.Label("坐标Y:", GUILayout.Width(75)); actionData.y = EditorGUILayout.IntField(actionData.y, GUILayout.Width(100)); GUILayout.EndHorizontal(); } else if (actionData.a == (int)SkillActionType.CRASH_TARGET) // 冲向目标 { GUILayout.BeginHorizontal(); GUILayout.Label("移动速度:", GUILayout.Width(75)); actionData.s = EditorGUILayout.IntField(actionData.s, GUILayout.Width(100)); GUILayout.Label("限制移动时间:", GUILayout.Width(75)); bool limitMove = actionData.l2 == 1; limitMove = EditorGUILayout.Toggle(limitMove, GUILayout.Width(40)); actionData.l2 = limitMove ? 1 : 0; GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("前排特效ID:", GUILayout.Width(75)); actionData.e1 = EditorGUILayout.IntField(actionData.e1, GUILayout.Width(100)); GUILayout.Label("后排特效ID:", GUILayout.Width(75)); actionData.e2 = EditorGUILayout.IntField(actionData.e2, GUILayout.Width(100)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("特效锁目标:", GUILayout.Width(75)); bool lookTarget = actionData.l == 1; lookTarget = EditorGUILayout.Toggle(lookTarget, GUILayout.Width(40)); actionData.l = lookTarget ? 1 : 0; GUILayout.EndHorizontal(); } //else if (actionData.a == (int)SkillActionType.CRASH_POS) // 冲向位置 //{ // GUILayout.BeginHorizontal(); // GUILayout.Label("坐标X:", GUILayout.Width(55)); // actionData.x = EditorGUILayout.IntField(actionData.x, GUILayout.Width(100)); // GUILayout.Label("坐标Y:", GUILayout.Width(55)); // actionData.y = EditorGUILayout.IntField(actionData.y, GUILayout.Width(100)); // GUILayout.EndHorizontal(); //} else if (actionData.a == (int)SkillActionType.SHOOT_BULLET) // 发射子弹 { GUILayout.BeginHorizontal(); GUILayout.Label("子弹速度:", GUILayout.Width(75)); actionData.s = EditorGUILayout.IntField(actionData.s, GUILayout.Width(100)); GUILayout.Label("限制移动时间:", GUILayout.Width(75)); bool limitMove = actionData.l2 == 1; limitMove = EditorGUILayout.Toggle(limitMove, GUILayout.Width(40)); actionData.l2 = limitMove ? 1 : 0; GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("前排特效ID:", GUILayout.Width(75)); actionData.e1 = EditorGUILayout.IntField(actionData.e1, GUILayout.Width(100)); GUILayout.Label("后排特效ID:", GUILayout.Width(75)); actionData.e2 = EditorGUILayout.IntField(actionData.e2, GUILayout.Width(100)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("发射点偏移X:", GUILayout.Width(75)); actionData.x = EditorGUILayout.IntField(actionData.x, GUILayout.Width(100)); GUILayout.Label("发射点偏移Y:", GUILayout.Width(75)); actionData.y = EditorGUILayout.IntField(actionData.y, GUILayout.Width(100)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("特效锁目标:", GUILayout.Width(75)); bool lookTarget = actionData.l == 1; lookTarget = EditorGUILayout.Toggle(lookTarget, GUILayout.Width(40)); actionData.l = lookTarget ? 1 : 0; GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("子弹时间1-3:", GUILayout.Width(75)); for (int i = 0; i < 3; ++i) { actionData.aB[i] = EditorGUILayout.FloatField(actionData.aB[i], GUILayout.Width(60)); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("子弹时间4-6:", GUILayout.Width(75)); for (int i = 3; i < 6; ++i) { actionData.aB[i] = EditorGUILayout.FloatField(actionData.aB[i], GUILayout.Width(60)); } GUILayout.EndHorizontal(); } else if (actionData.a == (int)SkillActionType.SHOOT_BULLET) // 敌人特效 { } else if (actionData.a == (int)SkillActionType.PLAY_EFFECT_LINK) // 链特效 { GUILayout.BeginHorizontal(); GUILayout.Label("链特效ID:", GUILayout.Width(75)); actionData.e1 = EditorGUILayout.IntField(actionData.e1, GUILayout.Width(100)); GUILayout.EndHorizontal(); } // 伤害集合 GUILayout.BeginVertical(); for (int i = 0; i < actionData.aH.Length; ++i) { GUILayout.BeginHorizontal(); GUILayout.Label("伤害id:", GUILayout.Width(75)); actionData.aH[i] = EditorGUILayout.IntField(actionData.aH[i], GUILayout.Width(100)); if (GUILayout.Button("-", GUILayout.Width(20))) { List <int> listId = new List <int>(actionData.aH); listId.RemoveAt(i); actionData.aH = listId.ToArray(); break; } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } GUILayout.EndVertical(); // 触发集合 GUILayout.BeginVertical(); for (int i = 0; i < actionData.aT.Length; ++i) { SkillTriggerData triData = actionData.aT[i]; GUILayout.BeginHorizontal(); GUILayout.Label("触发id:", GUILayout.Width(75)); triData.i = EditorGUILayout.IntField(triData.i, GUILayout.Width(60)); GUILayout.Label("触发时间:", GUILayout.Width(50)); triData.t = EditorGUILayout.FloatField(triData.t, GUILayout.Width(60)); if (GUILayout.Button("-", GUILayout.Width(20))) { List <SkillTriggerData> listData = new List <SkillTriggerData>(actionData.aT); listData.RemoveAt(i); actionData.aT = listData.ToArray(); break; } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } GUILayout.EndVertical(); GUILayout.BeginHorizontal(); // +按钮 if (GUILayout.Button("绑定伤害", GUILayout.Height(20), GUILayout.Width(150))) { List <int> listId = new List <int>(actionData.aH); listId.Add(0); actionData.aH = listId.ToArray(); } if (GUILayout.Button("绑定触发", GUILayout.Height(20), GUILayout.Width(150))) { List <SkillTriggerData> listData = new List <SkillTriggerData>(actionData.aT); listData.Add(new SkillTriggerData()); actionData.aT = listData.ToArray(); } GUILayout.EndHorizontal(); GUILayout.EndVertical(); }
// 绘制表现图标 // @dispData:伤害表现数据 private void DrawDisplayItem(SkillDisplayData dispData) { if (CheckDispIsValid(dispData.i)) { GUI.backgroundColor = Color.green; } else { GUI.backgroundColor = Color.red; } GUILayout.BeginVertical(new GUIStyle(EditorStyles.textField), GUILayout.Width(MENU_WIDTH), GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true)); GUI.backgroundColor = m_defaultBgClr; GUILayout.BeginHorizontal(); GUILayout.Label("表现id:", GUILayout.Width(55)); dispData.i = EditorGUILayout.IntField(dispData.i, GUILayout.Width(100)); if (GUILayout.Button("-", GUILayout.Width(20))) { List <SkillDisplayData> listDisp = new List <SkillDisplayData>(m_skillData.aD); listDisp.Remove(dispData); m_skillData.aD = listDisp.ToArray(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); // 第2行 GUILayout.Label("表现类型:", GUILayout.Width(55)); dispData.d = (int)EditorGUILayout.Popup(dispData.d, ARR_DISPLAY_TYPE_NAME, GUILayout.Width(100)); if (dispData.d == (int)SkillDisplayType.EFFECT) { GUILayout.Label("特效id:", GUILayout.Width(55)); dispData.e = EditorGUILayout.IntField(dispData.e, GUILayout.Width(100)); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); // 第2行 GUILayout.EndVertical(); }
// 绘制伤害 private void DrawHurm() { GUI.backgroundColor = Color.blue; GUILayout.BeginVertical(new GUIStyle(EditorStyles.textField), GUILayout.Width(MENU_WIDTH), GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true)); GUI.backgroundColor = m_defaultBgClr; // 标题 GUI.backgroundColor = Color.white; GUILayout.BeginVertical(); GUILayout.Label("伤害", m_styleTittle, GUILayout.Width(MENU_WIDTH), GUILayout.Height(40)); GUILayout.EndVertical(); // 标题 GUI.backgroundColor = m_defaultBgClr; GUI.backgroundColor = Color.white; GUILayout.BeginVertical(GUILayout.Height(630), GUILayout.ExpandHeight(true)); m_hurmScroPos = GUILayout.BeginScrollView(m_hurmScroPos, false, false); for (int i = 0; i < m_skillData.aH.Length; ++i) { SkillHurmData hurmData = m_skillData.aH[i]; DrawHurmItem(hurmData); } GUILayout.FlexibleSpace(); GUILayout.EndScrollView(); GUILayout.EndVertical(); GUI.backgroundColor = m_defaultBgClr; // +按钮 if (GUILayout.Button("+", GUILayout.Width(MENU_WIDTH), GUILayout.Height(40))) { List <SkillHurmData> listHarm = new List <SkillHurmData>(m_skillData.aH); SkillHurmData harmData = new SkillHurmData(); harmData.aD = new int[0]; harmData.i = GetMaxHarmDataId() + 1; listHarm.Add(harmData); m_skillData.aH = listHarm.ToArray(); } GUILayout.EndVertical(); // 绘制行为 }
// 绘制表现 private void DrawDisplay() { GUI.backgroundColor = Color.blue; GUILayout.BeginVertical(new GUIStyle(EditorStyles.textField), GUILayout.Width(MENU_WIDTH), GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true)); GUI.backgroundColor = m_defaultBgClr; // 标题 GUI.backgroundColor = Color.white; GUILayout.BeginVertical(); GUILayout.Label("表现", m_styleTittle, GUILayout.Width(MENU_WIDTH), GUILayout.Height(40)); GUILayout.EndVertical(); // 标题 GUI.backgroundColor = m_defaultBgClr; GUI.backgroundColor = Color.white; GUILayout.BeginVertical(GUILayout.Height(630), GUILayout.ExpandHeight(true)); m_displayScroPos = GUILayout.BeginScrollView(m_displayScroPos, false, false); for (int i = 0; i < m_skillData.aD.Length; ++i) { SkillDisplayData dispData = m_skillData.aD[i]; DrawDisplayItem(dispData); } GUILayout.FlexibleSpace(); GUILayout.EndScrollView(); GUILayout.EndVertical(); GUI.backgroundColor = m_defaultBgClr; // +按钮 if (GUILayout.Button("+", GUILayout.Width(MENU_WIDTH), GUILayout.Height(40))) { List <SkillDisplayData> listDisp = new List <SkillDisplayData>(m_skillData.aD); SkillDisplayData dData = new SkillDisplayData(); dData.i = GetMaxDisplayDataId() + 1; listDisp.Add(dData); m_skillData.aD = listDisp.ToArray(); } GUILayout.EndVertical(); // 绘制行为 }
// 绘制行为 private void DrawAction() { GUI.backgroundColor = Color.blue; GUILayout.BeginVertical(new GUIStyle(EditorStyles.textField), GUILayout.Width(MENU_WIDTH), GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true)); GUI.backgroundColor = m_defaultBgClr; // 标题 GUI.backgroundColor = Color.white; GUILayout.BeginVertical(); GUILayout.Label("技能行为", m_styleTittle, GUILayout.Width(MENU_WIDTH), GUILayout.Height(40)); GUILayout.EndVertical(); // 标题 GUI.backgroundColor = m_defaultBgClr; GUI.backgroundColor = Color.white; GUILayout.BeginVertical(GUILayout.Height(630), GUILayout.ExpandHeight(true)); m_actionScroPos = GUILayout.BeginScrollView(m_actionScroPos, false, false); for (int i = 0; i < m_skillData.aA.Length; ++i) { SkillActionData actionData = m_skillData.aA[i]; DrawActionItem(actionData); } GUILayout.FlexibleSpace(); GUILayout.EndScrollView(); GUILayout.EndVertical(); GUI.backgroundColor = m_defaultBgClr; // +按钮 if (GUILayout.Button("+", GUILayout.Width(MENU_WIDTH), GUILayout.Height(40))) { List <SkillActionData> listAction = new List <SkillActionData>(m_skillData.aA); SkillActionData actData = new SkillActionData(); actData.aH = new int[0]; actData.i = GetMaxActionDataId() + 1; listAction.Add(actData); m_skillData.aA = listAction.ToArray(); } GUILayout.EndVertical(); // 绘制行为 }
public void OnGUI() { Event e = Event.current; Vector2 mpos = e.mousePosition; bool forceRepaint = false; // if icon mode and no actions are found, that probably means icons failed to load. revert to text mode. int menuActionsCount = 0; for (int i = 0; i < m_Actions.Count; i++) { if (IsActionValid(m_Actions[i])) { menuActionsCount++; } } if (isIconMode && menuActionsCount < 1) { isIconMode = false; ProBuilderEditor.s_IsIconGui.value = isIconMode; CalculateMaxIconSize(); Debug.LogWarning("ProBuilder: Toolbar icons failed to load, reverting to text mode. Please ensure that the ProBuilder folder contents are unmodified. If the menu is still not visible, try closing and re-opening the Editor Window."); return; } int availableWidth = windowWidth; int availableHeight = windowHeight; bool isHorizontal = windowWidth > windowHeight * 2; if (m_IsHorizontalMenu != isHorizontal || m_Rows < 1 || m_Columns < 1) { CalculateMaxIconSize(); } if (e.type == EventType.Layout) { if (isHorizontal) { m_Rows = ((windowHeight - 4) / m_ContentHeight); m_Columns = System.Math.Max(windowWidth / m_ContentWidth, (menuActionsCount / m_Rows) + (menuActionsCount % m_Rows != 0 ? 1 : 0)); } else { m_Columns = System.Math.Max((windowWidth - 4) / m_ContentWidth, 1); m_Rows = (menuActionsCount / m_Columns) + (menuActionsCount % m_Columns != 0 ? 1 : 0); } } // happens when maximizing/unmaximizing the window if (m_Rows < 1 || m_Columns < 1) { return; } int contentWidth = (menuActionsCount / m_Rows) * m_ContentWidth + 4; int contentHeight = m_Rows * m_ContentHeight + 4; bool showScrollButtons = isHorizontal ? contentWidth > availableWidth : contentHeight > availableHeight; if (showScrollButtons) { availableHeight -= SCROLL_BTN_SIZE * 2; availableWidth -= SCROLL_BTN_SIZE * 2; } if (isHorizontal && e.type == EventType.ScrollWheel && e.delta.sqrMagnitude > .001f) { m_Scroll.value = new Vector2(m_Scroll.value.x + e.delta.y * 10f, m_Scroll.value.y); forceRepaint = true; } // the math for matching layout group width for icons is easy enough, but text // is a lot more complex. so for horizontal text toolbars always show the horizontal // scroll buttons. int maxHorizontalScroll = !isIconMode ? 10000 : contentWidth - availableWidth; int maxVerticalScroll = contentHeight - availableHeight; // only change before a layout event if (m_ShowScrollButtons != showScrollButtons && e.type == EventType.Layout) { m_ShowScrollButtons = showScrollButtons; } if (m_ShowScrollButtons) { if (isHorizontal) { GUILayout.BeginHorizontal(); GUI.enabled = ((Vector2)m_Scroll).x > 0; if (GUILayout.Button(scrollIconLeft, UI.EditorGUIUtility.ButtonNoBackgroundSmallMarginStyle, GUILayout.ExpandHeight(true))) { StartScrollAnimation(Mathf.Max(((Vector2)m_Scroll).x - availableWidth, 0f), 0f); } GUI.enabled = true; } else { GUI.enabled = ((Vector2)m_Scroll).y > 0; if (GUILayout.Button(scrollIconUp, UI.EditorGUIUtility.ButtonNoBackgroundSmallMarginStyle)) { StartScrollAnimation(0f, Mathf.Max(((Vector2)m_Scroll).y - availableHeight, 0f)); } GUI.enabled = true; } } m_Scroll.value = GUILayout.BeginScrollView(m_Scroll.value, false, false, GUIStyle.none, GUIStyle.none, GUIStyle.none); bool tooltipShown = false, hovering = false; Rect optionRect = new Rect(0f, 0f, 0f, 0f); GUILayout.BeginHorizontal(); // e.mousePosition != mpos at this point - @todo figure out why bool windowContainsMouse = window == EditorWindow.mouseOverWindow && mpos.x > 0 && mpos.x < window.position.width && mpos.y > 0 && mpos.y < window.position.height; int columnCount = 0; for (int actionIndex = 0; actionIndex < m_ActionsLength; actionIndex++) { MenuAction action = m_Actions[actionIndex]; if (!IsActionValid(action)) { continue; } if (isIconMode) { if (action.DoButton(isHorizontal, e.alt, ref optionRect, GUILayout.MaxHeight(m_ContentHeight + 12)) && !e.shift) { // test for alt click / hover optionRect.x -= m_Scroll.value.x; optionRect.y -= m_Scroll.value.y; if (windowContainsMouse && e.type != EventType.Layout && optionRect.Contains(e.mousePosition)) { hoveringTooltipName = action.tooltip.title + "_alt"; tooltipTimerRefresh = .5f; hovering = true; if (showTooltipTimer) { tooltipShown = true; ShowTooltip(optionRect, "Alt + Click for Options ", m_Scroll); } } } } else { if (m_Columns < 2) { action.DoButton(isHorizontal, e.alt, ref optionRect); } else { action.DoButton(isHorizontal, e.alt, ref optionRect, GUILayout.MinWidth(m_ContentWidth)); } } Rect buttonRect = GUILayoutUtility.GetLastRect(); if (windowContainsMouse && e.type != EventType.Layout && !hovering && buttonRect.Contains(e.mousePosition)) { hoveringTooltipName = action.tooltip.title; tooltipTimerRefresh = 1f; if (e.shift || showTooltipTimer) { tooltipShown = true; ShowTooltip(buttonRect, action.tooltip, m_Scroll); } hovering = true; forceRepaint = true; } if (++columnCount >= m_Columns) { columnCount = 0; GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); } } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.EndScrollView(); if (m_ShowScrollButtons) { if (isHorizontal) { GUI.enabled = m_Scroll.value.x < maxHorizontalScroll - 2; if (GUILayout.Button(scrollIconRight, UI.EditorGUIUtility.ButtonNoBackgroundSmallMarginStyle, GUILayout.ExpandHeight(true))) { StartScrollAnimation(Mathf.Min(m_Scroll.value.x + availableWidth + 2, maxHorizontalScroll), 0f); } GUI.enabled = true; GUILayout.EndHorizontal(); } else { GUI.enabled = m_Scroll.value.y < maxVerticalScroll - 2; if (GUILayout.Button(scrollIconDown, UI.EditorGUIUtility.ButtonNoBackgroundSmallMarginStyle)) { StartScrollAnimation(0f, Mathf.Min(m_Scroll.value.y + availableHeight + 2, maxVerticalScroll)); } GUI.enabled = true; } } if ((e.type == EventType.Repaint || e.type == EventType.MouseMove) && !tooltipShown) { TooltipEditor.Hide(); } if (e.type != EventType.Layout && !hovering) { tooltipTimer.item1 = ""; } if (forceRepaint || (EditorWindow.mouseOverWindow == this && e.delta.sqrMagnitude > .001f) || e.isMouse) { window.Repaint(); } }
void DrawDropZone() { GUILayout.BeginVertical(tk2dEditorSkin.SC_ListBoxBG, GUILayout.Width(leftBarWidth), GUILayout.ExpandHeight(true)); GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (DragAndDrop.objectReferences.Length == 0 && !SpriteCollection.Empty) { GUILayout.Label("Drop sprite here", tk2dEditorSkin.SC_DropBox); } else { GUILayout.Label("Drop sprites here", tk2dEditorSkin.SC_DropBox); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); GUILayout.EndVertical(); Rect rect = new Rect(0, 0, leftBarWidth, Screen.height); if (rect.Contains(Event.current.mousePosition)) { switch (Event.current.type) { case EventType.DragUpdated: if (IsValidDragPayload()) { DragAndDrop.visualMode = DragAndDropVisualMode.Copy; } else { DragAndDrop.visualMode = DragAndDropVisualMode.None; } break; case EventType.DragPerform: var droppedObjectsList = new List <Object>(); for (int i = 0; i < DragAndDrop.objectReferences.Length; ++i) { var type = DragAndDrop.objectReferences[i].GetType(); if (type == typeof(Texture2D)) { droppedObjectsList.Add(DragAndDrop.objectReferences[i]); } #if (UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_4_8 || UNITY_4_9) else if (type == typeof(UnityEngine.Object) && System.IO.Directory.Exists(DragAndDrop.paths[i])) #else else if (type == typeof(UnityEditor.DefaultAsset) && System.IO.Directory.Exists(DragAndDrop.paths[i])) #endif { droppedObjectsList.AddRange(AddTexturesInPath(DragAndDrop.paths[i])); } } deferredDroppedObjects = droppedObjectsList.ToArray(); Repaint(); break; } } }
protected virtual void OnGUI() { GUIStyle richText = EditorStyles.label; richText.richText = true; GUI.enabled = !EditorApplication.isUpdating && !EditorApplication.isCompiling && !EditorApplication.isPlayingOrWillChangePlaymode && !EditorApplication.isPaused; m_ScrollPosition = EditorGUILayout.BeginScrollView( m_ScrollPosition, false, true, GUIStyle.none, GUI.skin.verticalScrollbar, GUIStyle.none); EditorGUILayout.Separator(); EditorGUILayout.BeginVertical( GUILayout.MinWidth(400f), GUILayout.MaxWidth(Screen.width), GUILayout.ExpandWidth(true)); GUILayout.Label("Type Creator Currently is in Beta", EditorStyles.boldLabel); GUILayout.Label( "We want to hear your improvements and opinions. Please test all the features and report any bugs to us via Support. It can be used in prodcution.", EditorStyles.wordWrappedLabel); GUILayout.Label("Type Creator", EditorStyles.boldLabel); GUILayout.Label( "Here you can create custom Save Game Types and add save support to types that aren't supposed to be saved by searching through assemblies and types by clicks and automatically without writing a single line of code.", EditorStyles.wordWrappedLabel); EditorGUILayout.EndVertical(); EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal( GUILayout.MaxWidth(Screen.width), GUILayout.ExpandWidth(true)); EditorGUILayout.BeginVertical(); GUILayout.Label("Assemblies", EditorStyles.boldLabel); GUILayout.Label( "Here is a list of Assemblies, choose one to get a list of exported types, Use the search input to find the desired assembly.", EditorStyles.wordWrappedLabel); EditorGUILayout.Separator(); string assemblySearchPattern = EditorGUILayout.TextField("Search Pattern", m_AssemblySearchPattern); if (assemblySearchPattern != m_AssemblySearchPattern) { m_AssemblySearchPattern = assemblySearchPattern; GetAvailableAssemblies(); } if (GUILayout.Button("Reload Assemblies") || m_AvailableAssemblies == null || m_AvailableAssemblies.Length == 0) { GetAvailableAssemblies(); } m_AssembliesScrollViewPosition = EditorGUILayout.BeginScrollView( m_AssembliesScrollViewPosition, GUILayout.MaxHeight(300f), GUILayout.ExpandHeight(true), GUILayout.MinWidth(400f), GUILayout.MaxWidth(Screen.width), GUILayout.ExpandWidth(true)); m_SelectedAssemblyIndex = GUILayout.SelectionGrid(m_SelectedAssemblyIndex, m_AvailableAssembliesText, 3); if (m_SelectedAssemblyIndex >= m_AvailableAssemblies.Length) { m_SelectedAssembly = null; } else { if (m_SelectedAssembly != m_AvailableAssemblies[m_SelectedAssemblyIndex]) { m_SelectedAssembly = m_AvailableAssemblies[m_SelectedAssemblyIndex]; GetAvailableTypes(); } m_SelectedAssembly = m_AvailableAssemblies[m_SelectedAssemblyIndex]; } EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); EditorGUILayout.Separator(); EditorGUILayout.BeginVertical(); GUILayout.Label("Types", EditorStyles.boldLabel); GUILayout.Label( "Here is a list of Types, choose one to create a new Save Game Type from it, Use the search input to find desired type.", EditorStyles.wordWrappedLabel); EditorGUILayout.Separator(); string typeSearchPattern = EditorGUILayout.TextField("Search Pattern", m_TypeSearchPattern); if (typeSearchPattern != m_TypeSearchPattern) { m_TypeSearchPattern = typeSearchPattern; GetAvailableTypes(); } if (GUILayout.Button("Reload Types") || m_AvailableTypes == null || m_AvailableTypes.Length == 0) { GetAvailableTypes(); } m_TypesScrollViewPosition = EditorGUILayout.BeginScrollView( m_TypesScrollViewPosition, GUILayout.MaxHeight(300f), GUILayout.ExpandHeight(true), GUILayout.MinWidth(400f), GUILayout.MaxWidth(Screen.width), GUILayout.ExpandWidth(true)); m_SelectedTypeIndex = GUILayout.SelectionGrid(m_SelectedTypeIndex, m_AvailableTypesText, 3); if (m_SelectedTypeIndex >= m_AvailableTypes.Length) { m_SelectedType = null; } else { m_SelectedType = m_AvailableTypes[m_SelectedTypeIndex]; } EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); GUILayout.Space(15f); EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(); GUILayout.Label("Selected Type", EditorStyles.boldLabel); GUILayout.Label( "Here is the details and information of the selected type.", EditorStyles.wordWrappedLabel); EditorGUILayout.Separator(); if (m_SelectedType != null) { GUILayout.Label(string.Format("<b>Name</b>: {0}", m_SelectedType.Name), richText); GUILayout.Label(string.Format("<b>Assembly</b>: {0}", m_SelectedType.Assembly.FullName), richText); GUILayout.Label(string.Format("<b>Full Name</b>: {0}", m_SelectedType.GetFriendlyName()), richText); GUILayout.Label(string.Format("<b>Namespace</b>: {0}", m_SelectedType.Namespace), richText); GUILayout.Label(string.Format("<b>Is Value Type</b>: {0}", m_SelectedType.IsValueType), richText); } else { GUILayout.Label("<b>No Type is selected, Select one to see details.</b>", richText); } EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); EditorGUILayout.BeginVertical(); GUILayout.Label("Create Type", EditorStyles.boldLabel); GUILayout.Label( "Now specify the asset path to create the specified Save Game Type for the selected type.", EditorStyles.wordWrappedLabel); EditorGUILayout.EndVertical(); EditorGUILayout.BeginHorizontal(); m_AssetPath = EditorGUILayout.TextField("Asset Path", m_AssetPath); if (GUI.enabled) { GUI.enabled = m_SelectedType != null; } if (GUILayout.Button("Create Type")) { CreateType(m_AssetPath, m_SelectedType); } EditorGUILayout.EndHorizontal(); GUILayout.Label("Made with ❤️ by Bayat Games", EditorStyles.centeredGreyMiniLabel); EditorGUILayout.Separator(); EditorGUILayout.EndScrollView(); }
protected void showAbout() { EditorHelper.BannerOC(); GUILayout.Space(3); GUILayout.Label(Util.Constants.ASSET_NAME, EditorStyles.boldLabel); GUILayout.BeginHorizontal(); { GUILayout.BeginVertical(GUILayout.Width(60)); { GUILayout.Label("Version:"); GUILayout.Space(12); GUILayout.Label("Web:"); GUILayout.Space(2); GUILayout.Label("Email:"); } GUILayout.EndVertical(); GUILayout.BeginVertical(GUILayout.Width(170)); { GUILayout.Space(0); GUILayout.Label(Util.Constants.ASSET_VERSION); GUILayout.Space(12); EditorGUILayout.SelectableLabel(Util.Constants.ASSET_AUTHOR_URL, GUILayout.Height(16), GUILayout.ExpandHeight(false)); GUILayout.Space(2); EditorGUILayout.SelectableLabel(Util.Constants.ASSET_CONTACT, GUILayout.Height(16), GUILayout.ExpandHeight(false)); } GUILayout.EndVertical(); GUILayout.BeginVertical(GUILayout.ExpandWidth(true)); { //GUILayout.Space(0); } GUILayout.EndVertical(); GUILayout.BeginVertical(GUILayout.Width(64)); { if (GUILayout.Button(new GUIContent(string.Empty, EditorHelper.Logo_Asset, "Visit asset website"))) { Application.OpenURL(EditorConstants.ASSET_URL); } } GUILayout.EndVertical(); } GUILayout.EndHorizontal(); GUILayout.Label("© 2015-2019 by " + Util.Constants.ASSET_AUTHOR); EditorHelper.SeparatorUI(); GUILayout.BeginHorizontal(); { if (GUILayout.Button(new GUIContent(" AssetStore", EditorHelper.Logo_Unity, "Visit the 'Unity AssetStore' website."))) { Application.OpenURL(Util.Constants.ASSET_CT_URL); } if (GUILayout.Button(new GUIContent(" " + Util.Constants.ASSET_AUTHOR, EditorHelper.Logo_CT, "Visit the '" + Util.Constants.ASSET_AUTHOR + "' website."))) { Application.OpenURL(Util.Constants.ASSET_AUTHOR_URL); } } GUILayout.EndHorizontal(); EditorHelper.SeparatorUI(); aboutTab = GUILayout.Toolbar(aboutTab, new string[] { "Readme", "Versions", "SSML", "EML", "Update" }); if (aboutTab == 4) { scrollPosAboutUpdate = EditorGUILayout.BeginScrollView(scrollPosAboutUpdate, false, false); { Color fgColor = GUI.color; GUI.color = Color.yellow; if (updateStatus == UpdateStatus.NO_UPDATE) { GUI.color = Color.green; GUILayout.Label(updateText); } else if (updateStatus == UpdateStatus.UPDATE) { GUILayout.Label(updateText); if (GUILayout.Button(new GUIContent(" Download", "Visit the 'Unity AssetStore' to download the latest version."))) { UnityEditorInternal.AssetStore.Open("content/" + EditorConstants.ASSET_ID); } } else if (updateStatus == UpdateStatus.UPDATE_PRO) { GUILayout.Label(updateText); if (GUILayout.Button(new GUIContent(" Upgrade", "Upgrade to the PRO-version in the 'Unity AssetStore'."))) { Application.OpenURL(Util.Constants.ASSET_PRO_URL); } } else if (updateStatus == UpdateStatus.V2019) { GUILayout.Label(updateText); if (GUILayout.Button(new GUIContent(" Upgrade", "Upgrade to the 2019-version in the 'Unity AssetStore'."))) { Application.OpenURL(Util.Constants.ASSET_PRO_URL); } } else if (updateStatus == UpdateStatus.UPDATE_VERSION) { GUILayout.Label(updateText); if (GUILayout.Button(new GUIContent(" Upgrade", "Upgrade to the newer version in the 'Unity AssetStore'"))) { Application.OpenURL(Util.Constants.ASSET_CT_URL); } } else if (updateStatus == UpdateStatus.DEPRECATED) { GUILayout.Label(updateText); if (GUILayout.Button(new GUIContent(" More Information", "Visit the 'crosstales'-site for more information."))) { Application.OpenURL(Util.Constants.ASSET_AUTHOR_URL); } } else { GUI.color = Color.cyan; GUILayout.Label(updateText); } GUI.color = fgColor; } EditorGUILayout.EndScrollView(); if (updateStatus == UpdateStatus.NOT_CHECKED || updateStatus == UpdateStatus.NO_UPDATE) { bool isChecking = !(worker == null || (worker != null && !worker.IsAlive)); GUI.enabled = Util.Helper.isInternetAvailable && !isChecking; if (GUILayout.Button(new GUIContent(isChecking ? "Checking... Please wait." : " Check For Update", EditorHelper.Icon_Check, "Checks for available updates of " + Util.Constants.ASSET_NAME))) { worker = new System.Threading.Thread(() => UpdateCheck.UpdateCheckForEditor(out updateText, out updateStatus)); worker.Start(); } GUI.enabled = true; } } else if (aboutTab == 0) { if (readme == null) { string path = Application.dataPath + EditorConfig.ASSET_PATH + "README.txt"; try { readme = System.IO.File.ReadAllText(path); } catch (System.Exception) { readme = "README not found: " + path; } } scrollPosAboutReadme = EditorGUILayout.BeginScrollView(scrollPosAboutReadme, false, false); { GUILayout.Label(readme); } EditorGUILayout.EndScrollView(); } else if (aboutTab == 1) { if (versions == null) { string path = Application.dataPath + EditorConfig.ASSET_PATH + "Documentation/VERSIONS.txt"; try { versions = System.IO.File.ReadAllText(path); } catch (System.Exception) { versions = "VERSIONS not found: " + path; } } scrollPosAboutVersions = EditorGUILayout.BeginScrollView(scrollPosAboutVersions, false, false); { GUILayout.Label(versions); } EditorGUILayout.EndScrollView(); } else if (aboutTab == 2) { if (ssml == null) { string path = Application.dataPath + EditorConfig.ASSET_PATH + "Documentation/SSML.txt"; try { ssml = System.IO.File.ReadAllText(path); } catch (System.Exception) { ssml = "SSML not found: " + path; } } scrollPosAboutVersions = EditorGUILayout.BeginScrollView(scrollPosAboutVersions, false, false); { GUILayout.Label(ssml); } EditorGUILayout.EndScrollView(); } else { if (emotionml == null) { string path = Application.dataPath + EditorConfig.ASSET_PATH + "Documentation/EMOTIONML.txt"; try { emotionml = System.IO.File.ReadAllText(path); } catch (System.Exception) { emotionml = "EmotionML not found: " + path; } } scrollPosAboutVersions = EditorGUILayout.BeginScrollView(scrollPosAboutVersions, false, false); { GUILayout.Label(emotionml); } EditorGUILayout.EndScrollView(); } EditorHelper.SeparatorUI(); GUILayout.BeginHorizontal(); { if (GUILayout.Button(new GUIContent(string.Empty, EditorHelper.Social_Discord, "Communicate with us via 'Discord'."))) { Application.OpenURL(Util.Constants.ASSET_SOCIAL_DISCORD); } if (GUILayout.Button(new GUIContent(string.Empty, EditorHelper.Social_Facebook, "Follow us on 'Facebook'."))) { Application.OpenURL(Util.Constants.ASSET_SOCIAL_FACEBOOK); } if (GUILayout.Button(new GUIContent(string.Empty, EditorHelper.Social_Twitter, "Follow us on 'Twitter'."))) { Application.OpenURL(Util.Constants.ASSET_SOCIAL_TWITTER); } if (GUILayout.Button(new GUIContent(string.Empty, EditorHelper.Social_Linkedin, "Follow us on 'LinkedIn'."))) { Application.OpenURL(Util.Constants.ASSET_SOCIAL_LINKEDIN); } } GUILayout.EndHorizontal(); GUILayout.Space(6); }
void DrawMainWindow(int windowID) { //help button if (GUI.Button(new Rect(0, 0f, 20f, 18f), Collapsed? uncollapse_button : collapse_button, Styles.label)) { Collapsed = !Collapsed; draw_main_window = Collapsed; if (Collapsed) { ShowOnHover_fade_in_timer.Reset(); ShowOnHover_fade_out_timer.Reset(); update_collapsed_rect(); } } if (GUI.Button(new Rect(WindowPos.width - 20f, 0f, 20f, 18f), help_button, Styles.label)) { TCAManual.ToggleInstance(); } //vessel switching if (HaveRemoteControl) { if (GUI.Button(new Rect(22, 0f, 20f, 18f), prev_vessel_button, Styles.label)) { switch_vessel(FlightGlobals.Vessels.Next); } if (RemoteControl && GUI.Button(new Rect(44, 0f, 20f, 18f), active_vessel_button, Styles.label)) { onVesselChange(ActiveVesselTCA.vessel); } if (RemoteControl && GUI.Button(new Rect(WindowPos.width - 64f, 0f, 20f, 18f), switch_vessel_button, Styles.label)) { FlightGlobals.SetActiveVessel(vessel); } if (GUI.Button(new Rect(WindowPos.width - 42f, 0f, 20f, 18f), next_vessel_button, Styles.label)) { switch_vessel(FlightGlobals.Vessels.Prev); } } if (TCA.IsControllable) { GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); //tca toggle var enabled_style = Styles.inactive_button; if (CFG.Enabled) { enabled_style = Styles.enabled_button; } else if (!VSL.LandedOrSplashed && EnabledBlinker.On) { enabled_style = Styles.danger_button; } if (GUILayout.Button("Enabled", enabled_style, GUILayout.Width(70))) { TCA.ToggleTCA(); } #if DEBUG if (GUILayout.Button("ReGlobals", Styles.active_button, GUILayout.ExpandWidth(false))) { Globals.Load(); Styles.ConfigureButtons(); TCA.OnReloadGlobals(); } #endif //squad mode switch if (SQD != null) { SQD.Draw(); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.BeginVertical(Styles.white, GUILayout.MinHeight(ControlsHeight), GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(true)); if (ActiveTab != null) { ActiveTab.Draw(); } GUILayout.EndVertical(); tabs_scroll = GUILayout.BeginScrollView(tabs_scroll, Styles.white, GUILayout.ExpandHeight(true), GUILayout.Width(55)); for (int i = 0, AllTabsCount = AllTabs.Count; i < AllTabsCount; i++) { var t = AllTabs[i]; if (t.DrawTabButton(t == ActiveTab)) { ActiveTab = t; CFG.ActiveTab = i; } } GUILayout.EndScrollView(); GUILayout.EndHorizontal(); GUILayout.EndVertical(); } else { GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); VSL.Info.Draw(); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Label("Vessel is Uncontrollable", Styles.label, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); GUILayout.EndVertical(); } TooltipsAndDragWindow(); }
public static void DrawPresetWindow(int windowID) { GUIStyle yellowText = new GUIStyle(GUI.skin.label); yellowText.normal.textColor = Color.yellow; if (WorkingPreset == null) { SetNewWorkingPreset(new KCT_Preset(KCT_PresetManager.Instance.ActivePreset), false); //might need to copy instead of assign here presetIndex = KCT_PresetManager.Instance.GetIndex(WorkingPreset); } GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); //preset selector GUILayout.BeginVertical(); GUILayout.Label("Presets", yellowText, GUILayout.ExpandHeight(false)); //preset toolbar in a scrollview presetScrollView = GUILayout.BeginScrollView(presetScrollView, GUILayout.Width(presetPosition.width / 6.0f)); //TODO: update HighLogic.Skin.textArea string[] presetShortNames = KCT_PresetManager.Instance.PresetShortNames(true); if (presetIndex == -1) { SetNewWorkingPreset(null, true); /*presetIndex = presetShortNames.Length - 1; * WorkingPreset.name = "Custom"; * WorkingPreset.shortName = "Custom"; * WorkingPreset.description = "A custom set of configs."; * WorkingPreset.author = HighLogic.SaveFolder;*/ } if (changed && presetIndex < presetShortNames.Length - 1 && !KCT_Utilities.ConfigNodesAreEquivalent(WorkingPreset.AsConfigNode(), KCT_PresetManager.Instance.Presets[presetIndex].AsConfigNode())) //!KCT_PresetManager.Instance.PresetsEqual(WorkingPreset, KCT_PresetManager.Instance.Presets[presetIndex], true) { SetNewWorkingPreset(null, true); /*presetIndex = presetShortNames.Length - 1; //Custom preset * WorkingPreset.name = "Custom"; * WorkingPreset.shortName = "Custom"; * WorkingPreset.description = "A custom set of configs."; * WorkingPreset.author = HighLogic.SaveFolder;*/ } /* presetIndex = KCT_PresetManager.Instance.GetIndex(WorkingPreset); //Check that the current preset is equal to the expected one * if (presetIndex == -1) * presetIndex = presetNames.Length - 1;*/ int prev = presetIndex; presetIndex = GUILayout.SelectionGrid(presetIndex, presetShortNames, 1); if (prev != presetIndex) //If a new preset was selected { if (presetIndex != presetShortNames.Length - 1) { SetNewWorkingPreset(new KCT_Preset(KCT_PresetManager.Instance.Presets[presetIndex]), false); } else { SetNewWorkingPreset(null, true); /*WorkingPreset.name = "Custom"; * WorkingPreset.shortName = "Custom"; * WorkingPreset.description = "A custom set of configs."; * WorkingPreset.author = HighLogic.SaveFolder;*/ } } //presetIndex = GUILayout.Toolbar(presetIndex, presetNames); GUILayout.EndScrollView(); if (GUILayout.Button("Save as\nNew Preset", GUILayout.ExpandHeight(false))) { //create new preset SaveAsNewPreset(WorkingPreset); } if (WorkingPreset.AllowDeletion && presetIndex != presetShortNames.Length - 1 && GUILayout.Button("Delete Preset")) //allowed to be deleted and isn't Custom { DialogGUIBase[] options = new DialogGUIBase[2]; options[0] = new DialogGUIButton("Delete File", DeleteActivePreset); options[1] = new DialogGUIButton("Cancel", DummyVoid); MultiOptionDialog dialog = new MultiOptionDialog("deletePresetPopup", "Are you sure you want to delete the selected Preset, file and all? This cannot be undone!", "Confirm Deletion", null, options); PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), dialog, false, HighLogic.UISkin); } GUILayout.EndVertical(); //Main sections GUILayout.BeginVertical(); presetMainScroll = GUILayout.BeginScrollView(presetMainScroll); //Preset info section) GUILayout.BeginVertical(HighLogic.Skin.textArea); GUILayout.Label("Preset Name: " + WorkingPreset.name); GUILayout.Label("Description: " + WorkingPreset.description); GUILayout.Label("Author(s): " + WorkingPreset.author); GUILayout.EndVertical(); GUILayout.BeginHorizontal(); //Features section GUILayout.BeginVertical(); GUILayout.Label("Features", yellowText); GUILayout.BeginVertical(HighLogic.Skin.textArea); WorkingPreset.generalSettings.Enabled = GUILayout.Toggle(WorkingPreset.generalSettings.Enabled, "Mod Enabled", HighLogic.Skin.button); WorkingPreset.generalSettings.BuildTimes = GUILayout.Toggle(WorkingPreset.generalSettings.BuildTimes, "Build Times", HighLogic.Skin.button); WorkingPreset.generalSettings.ReconditioningTimes = GUILayout.Toggle(WorkingPreset.generalSettings.ReconditioningTimes, "Launchpad Reconditioning", HighLogic.Skin.button); WorkingPreset.generalSettings.ReconditioningBlocksPad = GUILayout.Toggle(WorkingPreset.generalSettings.ReconditioningBlocksPad, "Reconditioning Blocks Pad", HighLogic.Skin.button); WorkingPreset.generalSettings.TechUnlockTimes = GUILayout.Toggle(WorkingPreset.generalSettings.TechUnlockTimes, "Tech Unlock Times", HighLogic.Skin.button); WorkingPreset.generalSettings.KSCUpgradeTimes = GUILayout.Toggle(WorkingPreset.generalSettings.KSCUpgradeTimes, "KSC Upgrade Times", HighLogic.Skin.button); WorkingPreset.generalSettings.TechUpgrades = GUILayout.Toggle(WorkingPreset.generalSettings.TechUpgrades, "Upgrades From Tech Tree", HighLogic.Skin.button); WorkingPreset.generalSettings.SharedUpgradePool = GUILayout.Toggle(WorkingPreset.generalSettings.SharedUpgradePool, "Shared Upgrade Pool (KSCSwitcher)", HighLogic.Skin.button); GUILayout.BeginHorizontal(); GUILayout.Label("Starting Upgrades:"); WorkingPreset.generalSettings.StartingPoints = GUILayout.TextField(WorkingPreset.generalSettings.StartingPoints, GUILayout.Width(100)); GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.EndVertical(); //end Features GUILayout.BeginVertical(); //Begin time settings GUILayout.Label("Time Settings", yellowText); GUILayout.BeginVertical(HighLogic.Skin.textArea); GUILayout.BeginHorizontal(); GUILayout.Label("Overall Multiplier: "); double.TryParse(OMultTmp = GUILayout.TextField(OMultTmp, 10, GUILayout.Width(80)), out WorkingPreset.timeSettings.OverallMultiplier); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Build Effect: "); double.TryParse(BEffTmp = GUILayout.TextField(BEffTmp, 10, GUILayout.Width(80)), out WorkingPreset.timeSettings.BuildEffect); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Inventory Effect: "); double.TryParse(IEffTmp = GUILayout.TextField(IEffTmp, 10, GUILayout.Width(80)), out WorkingPreset.timeSettings.InventoryEffect); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Reconditioning Effect: "); double.TryParse(ReEffTmp = GUILayout.TextField(ReEffTmp, 10, GUILayout.Width(80)), out WorkingPreset.timeSettings.ReconditioningEffect); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Max Reconditioning: "); double.TryParse(MaxReTmp = GUILayout.TextField(MaxReTmp, 10, GUILayout.Width(80)), out WorkingPreset.timeSettings.MaxReconditioning); GUILayout.EndHorizontal(); GUILayout.Label("Rollout-Reconditioning Split:"); GUILayout.BeginHorizontal(); //GUILayout.Label("Rollout", GUILayout.ExpandWidth(false)); WorkingPreset.timeSettings.RolloutReconSplit = GUILayout.HorizontalSlider((float)Math.Floor(WorkingPreset.timeSettings.RolloutReconSplit * 100f), 0, 100) / 100.0; //GUILayout.Label("Recon.", GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); GUILayout.Label((Math.Floor(WorkingPreset.timeSettings.RolloutReconSplit * 100)) + "% Rollout, " + (100 - Math.Floor(WorkingPreset.timeSettings.RolloutReconSplit * 100)) + "% Reconditioning"); GUILayout.EndVertical(); //end time settings GUILayout.EndVertical(); GUILayout.EndHorizontal(); //end feature/time setting split //begin formula settings GUILayout.BeginVertical(); GUILayout.Label("Formula Settings (Advanced)", yellowText); GUILayout.BeginVertical(HighLogic.Skin.textArea); GUILayout.BeginHorizontal(); if (GUILayout.Button("Show/Hide Formulas")) { showFormula = !showFormula; } if (GUILayout.Button("View Wiki in Browser")) { Application.OpenURL("https://github.com/magico13/KCT/wiki"); } GUILayout.EndHorizontal(); if (showFormula) { //show half here, half on other side? Or all in one big list int textWidth = 350; GUILayout.BeginHorizontal(); GUILayout.Label("NodeFormula: "); WorkingPreset.formulaSettings.NodeFormula = GUILayout.TextField(WorkingPreset.formulaSettings.NodeFormula, GUILayout.Width(textWidth)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("UpgradeFunds: "); WorkingPreset.formulaSettings.UpgradeFundsFormula = GUILayout.TextField(WorkingPreset.formulaSettings.UpgradeFundsFormula, GUILayout.Width(textWidth)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("UpgradeScience: "); WorkingPreset.formulaSettings.UpgradeScienceFormula = GUILayout.TextField(WorkingPreset.formulaSettings.UpgradeScienceFormula, GUILayout.Width(textWidth)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("UpgradesForScience: "); WorkingPreset.formulaSettings.UpgradesForScience = GUILayout.TextField(WorkingPreset.formulaSettings.UpgradesForScience, GUILayout.Width(textWidth)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("ResearchFormula: "); WorkingPreset.formulaSettings.ResearchFormula = GUILayout.TextField(WorkingPreset.formulaSettings.ResearchFormula, GUILayout.Width(textWidth)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("EffectivePart: "); WorkingPreset.formulaSettings.EffectivePartFormula = GUILayout.TextField(WorkingPreset.formulaSettings.EffectivePartFormula, GUILayout.Width(textWidth)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("ProceduralPart: "); WorkingPreset.formulaSettings.ProceduralPartFormula = GUILayout.TextField(WorkingPreset.formulaSettings.ProceduralPartFormula, GUILayout.Width(textWidth)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("BPFormula: "); WorkingPreset.formulaSettings.BPFormula = GUILayout.TextField(WorkingPreset.formulaSettings.BPFormula, GUILayout.Width(textWidth)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("KSCUpgrade: "); WorkingPreset.formulaSettings.KSCUpgradeFormula = GUILayout.TextField(WorkingPreset.formulaSettings.KSCUpgradeFormula, GUILayout.Width(textWidth)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Reconditioning: "); WorkingPreset.formulaSettings.ReconditioningFormula = GUILayout.TextField(WorkingPreset.formulaSettings.ReconditioningFormula, GUILayout.Width(textWidth)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("BuildRate: "); WorkingPreset.formulaSettings.BuildRateFormula = GUILayout.TextField(WorkingPreset.formulaSettings.BuildRateFormula, GUILayout.Width(textWidth)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("UpgradeReset: "); WorkingPreset.formulaSettings.UpgradeResetFormula = GUILayout.TextField(WorkingPreset.formulaSettings.UpgradeResetFormula, GUILayout.Width(textWidth)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("InventorySale: "); WorkingPreset.formulaSettings.InventorySaleFormula = GUILayout.TextField(WorkingPreset.formulaSettings.InventorySaleFormula, GUILayout.Width(textWidth)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("RolloutCosts: "); WorkingPreset.formulaSettings.RolloutCostFormula = GUILayout.TextField(WorkingPreset.formulaSettings.RolloutCostFormula, GUILayout.Width(textWidth)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("NewLaunchPadCost: "); WorkingPreset.formulaSettings.NewLaunchPadCostFormula = GUILayout.TextField(WorkingPreset.formulaSettings.NewLaunchPadCostFormula, GUILayout.Width(textWidth)); GUILayout.EndHorizontal(); } GUILayout.EndVertical(); GUILayout.EndVertical(); //end formula settings GUILayout.EndScrollView(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Save", GUILayout.ExpandWidth(false))) { KCT_PresetManager.Instance.ActivePreset = WorkingPreset; KCT_PresetManager.Instance.SaveActiveToSaveData(); WorkingPreset = null; showSettings = false; if (!KCT_PresetManager.Instance.ActivePreset.generalSettings.Enabled) { KCT_Utilities.DisableModFunctionality(); } //KCT_GameStates.settings.enabledForSave = KCT_PresetManager.Instance.ActivePreset.generalSettings.Enabled; KCT_GameStates.settings.MaxTimeWarp = newTimewarp; KCT_GameStates.settings.ForceStopWarp = forceStopWarp; KCT_GameStates.settings.DisableAllMessages = disableAllMsgs; KCT_GameStates.settings.OverrideLaunchButton = overrideLaunchBtn; KCT_GameStates.settings.Debug = debug; KCT_GameStates.settings.AutoKACAlarms = autoAlarms; KCT_GameStates.settings.PreferBlizzyToolbar = useBlizzyToolbar; KCT_GameStates.settings.CheckForDebugUpdates = debugUpdateChecking; KCT_GameStates.settings.Save(); showSettings = false; if (!PrimarilyDisabled && !showFirstRun) { ResetBLWindow(); if (KCT_Events.instance.KCTButtonStock != null) { KCT_Events.instance.KCTButtonStock.SetTrue(); } else { showBuildList = true; } } if (!KCT_PresetManager.Instance.ActivePreset.generalSettings.Enabled) { InputLockManager.RemoveControlLock("KCTKSCLock"); } for (int j = 0; j < KCT_GameStates.TechList.Count; j++) { KCT_GameStates.TechList[j].UpdateBuildRate(j); } foreach (KCT_KSC ksc in KCT_GameStates.KSCs) { ksc.RecalculateBuildRates(); ksc.RecalculateUpgradedBuildRates(); } KCT_GUI.ResetFormulaRateHolders(); } if (GUILayout.Button("Cancel", GUILayout.ExpandWidth(false))) { WorkingPreset = null; showSettings = false; if (!PrimarilyDisabled && !showFirstRun) { ResetBLWindow(); if (KCT_Events.instance.KCTButtonStock != null) { KCT_Events.instance.KCTButtonStock.SetTrue(); } else { showBuildList = true; } } for (int j = 0; j < KCT_GameStates.TechList.Count; j++) { KCT_GameStates.TechList[j].UpdateBuildRate(j); } } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.EndVertical(); //end column 2 GUILayout.BeginVertical(GUILayout.Width(100)); //Start general settings GUILayout.Label("General Settings", yellowText); GUILayout.Label("NOTE: Affects all saves!", yellowText); GUILayout.BeginVertical(HighLogic.Skin.textArea); GUILayout.Label("Max Timewarp"); GUILayout.BeginHorizontal(); if (GUILayout.Button("-", GUILayout.ExpandWidth(false))) { newTimewarp = Math.Max(newTimewarp - 1, 0); } //current warp setting GUILayout.Label(TimeWarp.fetch.warpRates[newTimewarp] + "x"); if (GUILayout.Button("+", GUILayout.ExpandWidth(false))) { newTimewarp = Math.Min(newTimewarp + 1, TimeWarp.fetch.warpRates.Length - 1); } GUILayout.EndHorizontal(); forceStopWarp = GUILayout.Toggle(forceStopWarp, "Auto Stop TimeWarp", HighLogic.Skin.button); autoAlarms = GUILayout.Toggle(autoAlarms, "Auto KAC Alarms", HighLogic.Skin.button); overrideLaunchBtn = GUILayout.Toggle(overrideLaunchBtn, "Override Launch Button", HighLogic.Skin.button); useBlizzyToolbar = GUILayout.Toggle(useBlizzyToolbar, "Use Toolbar Mod", HighLogic.Skin.button); disableAllMsgs = !GUILayout.Toggle(!disableAllMsgs, "Use Message System", HighLogic.Skin.button); debug = GUILayout.Toggle(debug, "Debug Logging", HighLogic.Skin.button); #if DEBUG debugUpdateChecking = GUILayout.Toggle(debugUpdateChecking, "Check for Dev Updates", HighLogic.Skin.button); #endif GUILayout.EndVertical(); GUILayout.EndVertical(); GUILayout.EndHorizontal(); //end main split GUILayout.EndVertical(); //end window changed = GUI.changed; if (!Input.GetMouseButtonDown(1) && !Input.GetMouseButtonDown(2)) { GUI.DragWindow(); } }
private void ShowModuleTypePicker() { if (list == null) { UpdateList(); return; } const float buttonWidth = 200f; Rect rect = GUILayoutUtility.GetRect(buttonWidth, 9999f, EditorGUIUtility.singleLineHeight, EditorGUIUtility.singleLineHeight, GUILayout.ExpandHeight(false)); rect.y -= 4f; var width = rect.width; rect.width = buttonWidth; rect.x += (width - buttonWidth); if (allowMultipleImplementations || list.Count == 0) { if (GUI.Button(rect, new GUIContent("Add module", EditorGUIUtility.FindTexture("d_Toolbar Plus")), Style.addModuleButtonStyle)) { var ignoreList = new List <Type>(); if (allowDuplicateImplementations == false) { ignoreList = list.Select(o => o.GetType()).ToList(); ignoreList.AddRange(ReflectionUtility.GetAllTypesThatImplement(typeof(T)).Where(o => typeof(UnityEngine.Component).IsAssignableFrom(o) == false)); } var window = ScriptPickerEditor.Get(typeof(T), ignoreList.ToArray()); window.Show(); window.OnPickObject += type => { addModule(type); }; } } }
void OnGUI() { if (this._recompile == null) { // if yes assume recompile then create a reference to a recompile class this._recompile = new RecompileClass(); //little hack for the editor,otherwise on start we have no OSC Connections in the Editor GUI. ([InitializeOnLoad] didn't work) //Init(); _GetOSCConnectionInstances(); } EditorGUI.BeginChangeCheck(); _editorWidth = position.width; if (_config.isOSCTracing) { _editorWidth = _editorWidth - TRACEWIDTH; } if (_config.mySkin != null) { GUI.skin = _config.mySkin; } //Rect for Learning Border Rect r_learn = new Rect(0f, 0f, position.width, position.height); EditorGUILayout.BeginHorizontal(); #region GUI_LEFT EditorGUILayout.BeginVertical(GUILayout.ExpandHeight(true)); if (_config == null) { Rect area = GUILayoutUtility.GetRect(500.0f, 80.0f); EditorGUI.HelpBox(area, "No configuration could be loaded! The Editor could not work in this state.", MessageType.Error); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); return; } GUILayout.Space(4); #region header #region logo GUILayout.BeginHorizontal(); GUILayout.Space(4); UniOSCUtils.DrawTexture(_config.tex_logo); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); #endregion logo GUILayout.BeginHorizontal(); GUI.backgroundColor = _config.isOSCTracing ? Color.green : Color.white; _config.isOSCTracing = GUILayout.Toggle(_config.isOSCTracing, new GUIContent("Trace OSC"), GUI.skin.button, GUILayout.Height(30f), GUILayout.Width(100f)); //OSCConnectionEditor.tex2 GUI.backgroundColor = Color.white; if (GUILayout.Button(new GUIContent("Create OSC Connection", ""), GUILayout.Width(160f), GUILayout.Height(30f))) { _CreateOSCConnection(); Init(); } ; if (GUILayout.Button("Create OSC Mapping File", GUILayout.Height(30f), GUILayout.Width(160f))) { _CreateOSCMappingFile(); } if (GUILayout.Button("Create OSC Session File", GUILayout.Height(30f), GUILayout.Width(160f))) { _CreateOSCSessionFile(); } GUI.backgroundColor = _config.isOSCLearning ? Color.green : Color.white; _config.isOSCLearning = GUILayout.Toggle(_config.isOSCLearning, new GUIContent("Learn OSC"), GUI.skin.button, GUILayout.Height(30f), GUILayout.Width(100f)); //OSCConnectionEditor.tex2 GUI.backgroundColor = Color.white; if (_isOSCLearning != _config.isOSCLearning) { //Toggle was clicked _isOSCLearning = _config.isOSCLearning; OSCLearning(_config.isOSCLearning); //EditorUtility.SetDirty(_config); } //_config.isEditorEnabled = UniOSCConnection.isEditorEnabled; GUI.backgroundColor = _config.isEditorEnabled ? Color.green : Color.white; _config.isEditorEnabled = GUILayout.Toggle(_config.isEditorEnabled, new GUIContent("Editor Mode"), GUI.skin.button, GUILayout.Height(30f), GUILayout.Width(100f)); GUI.backgroundColor = Color.white; UniOSCConnection.isEditorEnabled = _config.isEditorEnabled; GUILayout.EndHorizontal(); #endregion header GUILayout.Space(5); _DrawLineH(_editorWidth - 20f); GUILayout.Space(5); #region Connection GUILayout.BeginHorizontal(); GUIStyle gsCon = new GUIStyle(GUI.skin.label); gsCon.fontSize = 18; GUILayout.Label("OSC Connection", gsCon); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(3); OnGUI_OSCConnection(); #endregion Connection #region space GUI.contentColor = Color.white; GUI.backgroundColor = Color.white; GUILayout.Space(5); _DrawLineH(_editorWidth - 20f); GUILayout.Space(5); #endregion space #region toolbar _config.toolbarInt = GUILayout.Toolbar(_config.toolbarInt, toolbarStrings, GUILayout.Width(200 * toolbarStrings.Count()), GUILayout.Height(30f)); #endregion toolbar GUILayout.Space(5); // _DrawLineH(_editorWidth-20f); GUILayout.Space(5); #region Mapping switch (_config.toolbarInt) { case 0: OnGUI_OSCMapping(); break; case 1: OnGUI_OSCSessionFiles(); break; default: OnGUI_DefaultContent(); break; } #endregion Mapping #region footer GUI.contentColor = Color.white; if (_osConnectionIDList.Count > 0) { _DrawLineH(_editorWidth - 20f); GUILayout.Space(10f); } if (GUILayout.Button(new GUIContent("Refresh Editor", "Refresh the Editor. Reloads the available data"), GUILayout.Width(150), GUILayout.Height(30f))) { Init(); } ; GUILayout.Space(5f); #endregion footer EditorGUILayout.EndVertical(); #endregion GUI_LEFT #region GUI_RIGHT if (_config.isOSCTracing) { Rect r_tracing = GUILayoutUtility.GetRect(1.0f, position.height - 0f); GUI.Box(r_tracing, "", GUI.skin.box); //,GUI.skin.box GUI.skin.customStyles[1] OnGUI_Trace(); } #endregion GUI_RIGHT EditorGUILayout.EndHorizontal(); //draw Learning Border if (_config.isOSCLearning) { GUI.backgroundColor = Color.red; GUI.Box(r_learn, "", _config.learnStyle); GUI.backgroundColor = Color.white; } if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(_config); } }
void OnGUI() { var worldsAppeared = noWorlds && World.AllWorlds.Count > 0; noWorlds = World.AllWorlds.Count == 0; if (noWorlds) { } if (worldsAppeared) { worldListView.SetWorlds(World.AllWorlds); } GUILayout.BeginHorizontal(); GUILayout.BeginVertical(); worldListView.OnGUI(GUILayoutUtility.GetRect(GUIContent.none, GUIStyle.none, GUILayout.Height(kWorldListHeight), GUILayout.ExpandWidth(true))); if (currentWorldSelection == null) { GUIHelpers.ShowCenteredNotification(new Rect(Vector2.zero, position.size), "No ComponentSystems loaded. (Try pushing Play)"); } else { systemGraphView.OnGUIArrows(); BeginWindows(); systemGraphView.OnGUIWindows(); EndWindows(); } GUILayout.EndVertical(); playerLoopListView.OnGUI(GUILayoutUtility.GetRect(GUIContent.none, GUIStyle.none, GUILayout.ExpandHeight(true), GUILayout.Width(300f))); GUILayout.EndHorizontal(); }
void OnGUI_Trace() { EditorGUILayout.BeginVertical(GUILayout.Width(TRACEWIDTH - 20f)); GUI.contentColor = Color.yellow; _config.configTraceScrollpos = GUILayout.BeginScrollView(_config.configTraceScrollpos, GUILayout.Height(position.height - 100f), GUILayout.ExpandHeight(false)); // GUILayout!!! not EditorGUILayout! So we can select. GUILayout.TextArea(_oscTraceStr, GUILayout.ExpandHeight(true)); GUILayout.EndScrollView(); GUI.contentColor = Color.white; GUILayout.FlexibleSpace(); EditorGUI.BeginChangeCheck(); GUI.backgroundColor = _config.isLastMessageTracing ? Color.green : Color.white; _config.isLastMessageTracing = GUILayout.Toggle(_config.isLastMessageTracing, "Display only last message", "button", GUILayout.Height(20)); GUI.backgroundColor = Color.white; if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(_config); } GUILayout.Space(5); if (GUILayout.Button("Clear Trace", GUILayout.Height(30))) { _oscTraceStr = ""; _osctraceStrb = new StringBuilder(16384); } GUILayout.Space(8f); EditorGUILayout.EndVertical(); }
protected void v_section(float section_width, float section_height, bool expand_height, Content content) { GUILayout.BeginVertical(get_section_style(), GUILayout.Width(section_width), GUILayout.MaxWidth(section_width), GUILayout.Height(section_height), GUILayout.MaxHeight(section_height), GUILayout.ExpandHeight(expand_height) ); content(section_width); GUILayout.EndVertical(); }
public void DoGUI(HierarchyFrameDataView frameDataView, bool fetchData, ref bool updateViewLive) { using (m_DoGUIMarker.Auto()) { if (Event.current.type != EventType.Layout && m_ThreadIndexDuringLastNonLayoutEvent != threadIndex) { m_ThreadIndexDuringLastNonLayoutEvent = threadIndex; EditorGUIUtility.ExitGUI(); } InitIfNeeded(); var collectingSamples = ProfilerDriver.enabled && (ProfilerDriver.profileEditor || EditorApplication.isPlaying); var isSearchAllowed = string.IsNullOrEmpty(treeView.searchString) || !(collectingSamples && ProfilerDriver.deepProfiling); var isDataAvailable = frameDataView != null && frameDataView.valid; var showDetailedView = isDataAvailable && m_DetailedViewType != DetailedViewType.None; if (showDetailedView) { SplitterGUILayout.BeginHorizontalSplit(m_DetailedViewSpliterState); } // Hierarchy view area GUILayout.BeginVertical(); DrawToolbar(frameDataView, showDetailedView, ref updateViewLive); if (!string.IsNullOrEmpty(dataAvailabilityMessage)) { GUILayout.Label(dataAvailabilityMessage, BaseStyles.label); } else if (!isDataAvailable) { if (!fetchData && !updateViewLive) { GUILayout.Label(BaseStyles.liveUpdateMessage, BaseStyles.label); } else { GUILayout.Label(BaseStyles.noData, BaseStyles.label); } } else if (!isSearchAllowed) { GUILayout.Label(BaseStyles.disabledSearchText, BaseStyles.label); } else { var rect = GUILayoutUtility.GetRect(GUIContent.none, GUIStyle.none, GUILayout.ExpandHeight(true), GUILayout.ExpandHeight(true)); m_TreeView.SetFrameDataView(frameDataView); m_TreeView.OnGUI(rect); } GUILayout.EndVertical(); if (showDetailedView) { GUILayout.BeginVertical(); // Detailed view area EditorGUILayout.BeginHorizontal(BaseStyles.toolbar); DrawDetailedViewPopup(); GUILayout.FlexibleSpace(); cpuModule.DrawOptionsMenuPopup(); EditorGUILayout.EndHorizontal(); switch (m_DetailedViewType) { case DetailedViewType.Objects: detailedObjectsView.DoGUI(BaseStyles.header, frameDataView, m_TreeView.GetSelection()); break; case DetailedViewType.CallersAndCallees: detailedCallsView.DoGUI(BaseStyles.header, frameDataView, m_TreeView.GetSelection()); break; } GUILayout.EndVertical(); SplitterGUILayout.EndHorizontalSplit(); } HandleKeyboardEvents(); } }
void OnGUI() { if (normalStyle == null) { normalStyle = new GUIStyle() { alignment = TextAnchor.LowerLeft, } } ; if (selectStyle == null) { selectStyle = new GUIStyle(); selectStyle.alignment = TextAnchor.LowerLeft; selectStyle.normal.background = Resources.Load <Texture2D>("selected"); selectStyle.wordWrap = true; } GUILayout.BeginHorizontal(); // Left view posLeft = GUILayout.BeginScrollView(posLeft, GUILayout.Width(splitterPos), GUILayout.MaxWidth(splitterPos), GUILayout.MinWidth(splitterPos)); DrawLeft(); GUILayout.EndScrollView(); // Splitter GUILayout.Box("", GUILayout.Width(splitterWidth), GUILayout.MaxWidth(splitterWidth), GUILayout.MinWidth(splitterWidth), GUILayout.ExpandHeight(true)); splitterRect = GUILayoutUtility.GetLastRect(); // Right view posRight = GUILayout.BeginScrollView(posRight, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); DrawRight(); GUILayout.EndScrollView(); GUILayout.EndHorizontal(); // Splitter events if (Event.current != null) { switch (Event.current.rawType) { case EventType.MouseDown: if (splitterRect.Contains(Event.current.mousePosition)) { dragging = true; } break; case EventType.MouseDrag: if (dragging) { splitterPos += Event.current.delta.x; splitterPos = Mathf.Clamp(splitterPos, 200, 400); Repaint(); } break; case EventType.MouseUp: if (dragging) { dragging = false; } break; } } } void DrawLeft() { GUILayout.BeginVertical(); if (GUILayout.Button("Refresh", GUILayout.Width(60))) { selected = -1; GetAtlasNames(); if (infoNamesArray != null && infoNamesArray.Length > 0) { SetSelectAtlas(0); } return; } GUILayout.Space(8); if (infoNamesArray == null || infoNamesArray.Length < 0) { return; } for (int i = 0; i < infoNamesArray.Length; i++) { int idx = i; GUILayout.BeginHorizontal(); if (GUILayout.Button(infoNamesArray[i], i == selected? selectStyle : normalStyle)) { SetSelectAtlas(idx); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); } void DrawRight() { GUILayout.BeginVertical(); if (selected >= 0) { GUILayout.BeginHorizontal(); if (GUILayout.Button("View In SpritePacker Windom", GUILayout.Width(200))) { ShowInPackerWindom(selected); } GUILayout.Space(10); GUILayout.Label("Atlas Name:\t" + infoNamesArray[selected]); GUILayout.EndHorizontal(); } if (texture != null) { GUILayout.Space(20); GUILayout.Label(String.Format("{0}x{1},{2}", texture.width, texture.height, texture.format)); float zoom = 1; if (texture.width > 1024) { zoom = 1024 * 1.0f / texture.width; } if (texture.height > 512) { zoom = Mathf.Min(zoom, 512 * 1.0f / texture.height); } Rect rect = new Rect(0, 60, texture.width * zoom, texture.height * zoom); EditorGUI.DrawTextureTransparent(rect, texture); } GUILayout.EndVertical(); }
void OnGUI() { titleContent.text = "打包设置编辑器"; UpdateRelyPackageNames(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("过滤器:"); RelyMaskFilter = EditorGUILayout.MaskField(RelyMaskFilter, RelyPackageNames); bundleQuery = EditorGUILayout.TextField("", bundleQuery); EditorGUILayout.EndHorizontal(); scrollPos = GUILayout.BeginScrollView(scrollPos, GUILayout.ExpandHeight(false)); isFoldRelyPackages = EditorGUILayout.Foldout(isFoldRelyPackages, "依赖包:"); if (isFoldRelyPackages) { //依赖包视图 RelyPackagesView(); EditorGUILayout.Space(); } EditorGUI.indentLevel = 0; isFoldBundles = EditorGUILayout.Foldout(isFoldBundles, "AssetsBundle:"); if (isFoldBundles) { //bundle包视图 BundlesView(); } GUILayout.EndScrollView(); LogsScrollPos = GUILayout.BeginScrollView(LogsScrollPos, GUILayout.ExpandHeight(true)); EditorGUI.indentLevel = 0; isFoldLog = EditorGUILayout.Foldout(isFoldLog, "提示信息:"); if (isFoldLog) { //提示信息视图 LogView(); } GUILayout.EndScrollView(); EditorGUI.indentLevel = 0; GUILayout.BeginHorizontal(); checkMaterial = EditorGUILayout.Toggle("检查材质球和贴图", checkMaterial); GUILayout.EndHorizontal(); HotUpdateConfigGUI(); if (GUILayout.Button("检查依赖关系")) { CheckPackage(); } //if (GUILayout.Button("重新添加资源文件并保存")) //{ // AddAllResourceBundle(); //添加资源文件 // ArrangeBundlesByLayer(); //整理资源路径 // CreatPackageFile(); //保存编辑器文件 // CheckAndCreatBundelPackageConfig(); //生成资源路径文件 //} if (GUILayout.Button("保存游戏资源路径文件")) { CreatePackageFile(); //保存编辑器文件 CheckAndCreatBundelPackageConfig(); //生成资源路径文件 } if (!isPacking) { if (GUILayout.Button("打包")) { CheckAndPackage(); } } else { if (GUILayout.Button("终止打包")) { EndPackage(); } } if (GUILayout.Button("生成MD5")) { CheckAndCreatBundelPackageConfig(); } GUILayout.BeginHorizontal(); VersionService.LargeVersion = EditorGUILayout.IntField("large", VersionService.LargeVersion); VersionService.SmallVersion = EditorGUILayout.IntField("small", VersionService.SmallVersion); if (GUILayout.Button("保存版本文件")) { VersionService.CreateVersionFile(); } GUILayout.EndHorizontal(); if (isContent) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(messageContent); if (GUILayout.Button("关闭")) { isContent = false; messageContent = ""; } if (errorCount != 0 || warnCount != 0) { if (GUILayout.Button("清除")) { isContent = false; messageContent = ""; ClearCheckLog(); } } EditorGUILayout.EndHorizontal(); } if (isProgress) { EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUI.ProgressBar(new Rect(3, position.height - 22, position.width - 6, 18), progress, progressContent); } }
void OnGUI() { EditorGUILayout.HelpBox("Cloud URL: " + Config.CloudUrl, MessageType.Info); EditorGUILayout.HelpBox("SimID: " + Config.SimID, MessageType.None); if (!String.IsNullOrEmpty(ErrorMessage)) { EditorGUILayout.HelpBox(ErrorMessage, MessageType.Warning); } if (EditorApplication.isPlayingOrWillChangePlaymode) { EditorGUILayout.HelpBox("Disabled during play mode", MessageType.Info); return; } if (updating) { EditorGUILayout.HelpBox("Updating...", MessageType.Info); return; } EditorGUI.BeginChangeCheck(); if (GUILayout.Button("Disconnect")) { API.Disconnect(); } if (GUILayout.Button("Refresh")) { Refresh(); } ScrollPos = EditorGUILayout.BeginScrollView(ScrollPos); foreach (PropertyInfo prop in typeof(SimulationData).GetProperties()) { if (prop.Name == "Id" || prop.Name == "UpdatedAt" || prop.Name == "CreatedAt" || prop.Name == "OwnerId" || prop.Name == "TestReportId") continue; object value = prop.GetValue(DeveloperSimulation); if (prop.PropertyType == typeof(bool)) { prop.SetValue(DeveloperSimulation, EditorGUILayout.ToggleLeft(prop.Name, ((bool?)value).Value)); } else if (prop.PropertyType == typeof(int)) { prop.SetValue(DeveloperSimulation, EditorGUILayout.IntField(prop.Name, ((int?)value).Value)); } else if (prop.PropertyType == typeof(float)) { prop.SetValue(DeveloperSimulation, EditorGUILayout.FloatField(prop.Name, ((float?)value).Value)); } else if (prop.PropertyType == typeof(string)) { prop.SetValue(DeveloperSimulation, EditorGUILayout.TextField(prop.Name, (string)value)); } else if (prop.PropertyType == typeof(DateTime)) { var userValue = EditorGUILayout.TextField(prop.Name, ((DateTime)value).ToString()); if (DateTime.TryParse(userValue, out DateTime dt)) { prop.SetValue(DeveloperSimulation, dt); } } else if (prop.PropertyType == typeof(int?)) { int? val = (int?)value; EditorGUILayout.BeginHorizontal(); bool doSet = EditorGUILayout.ToggleLeft("enable " + prop.Name, val.HasValue); EditorGUI.BeginDisabledGroup(!doSet); int? newValue = EditorGUILayout.IntField(prop.Name, val.HasValue ? val.Value : 0, GUILayout.ExpandWidth(true)); prop.SetValue(DeveloperSimulation, doSet ? newValue : null); EditorGUI.EndDisabledGroup(); GUILayout.EndHorizontal(); } else if (prop.PropertyType == typeof(VehicleData[])) { VehicleSetup = EditorGUILayout.Foldout(VehicleSetup, "EGO Setup"); if (VehicleSetup) { // a list of tuples (display:"name to show", data:string or VehicleDetailData ) var vehicleChoices = VehicleChoices; if (vehicleChoices.Count > 0) { EditorGUI.indentLevel++; var newIndex = EditorGUILayout.Popup(CurrentVehicleIndex, vehicleChoices.Select(v => v.display).ToArray()); var vehicle = SetVehicleFromSelectionIndex(vehicleChoices, newIndex); if (vehicle.Id.EndsWith(".prefab")) { vehicle.Bridge.Type = EditorGUILayout.TextField("Bridge Type", vehicle.Bridge.Type); vehicle.Bridge.ConnectionString = EditorGUILayout.TextField("Bridge Connection", vehicle.Bridge.ConnectionString); EditorGUILayout.LabelField("json sensor config"); SensorScratchPad = EditorGUILayout.TextArea(SensorScratchPad, GUILayout.ExpandHeight(true)); try { vehicle.Sensors = JsonConvert.DeserializeObject<SensorData[]>(SensorScratchPad); if (vehicle.Sensors == null) { vehicle.Sensors = new SensorData[0]; } } catch (Exception e) { EditorGUILayout.HelpBox(e.Message, MessageType.Error); } } else { if (vehicle.Bridge != null) { vehicle.Bridge.ConnectionString = EditorGUILayout.TextField("Bridge Connection", vehicle.Bridge.ConnectionString); EditorGUI.BeginDisabledGroup(true); EditorGUILayout.TextField("Bridge Type", vehicle.Bridge.Type); EditorGUILayout.TextField("Bridge Name", vehicle.Bridge.Name); EditorGUILayout.TextField("Bridge AssetGuid", vehicle.Bridge.AssetGuid); EditorGUILayout.LabelField("json sensor config"); EditorGUILayout.TextArea(Newtonsoft.Json.JsonConvert.SerializeObject(vehicle.Sensors, JsonSettings.camelCase), GUILayout.Height(200)); EditorGUI.EndDisabledGroup(); } } EditorGUI.indentLevel--; } else { EditorGUILayout.HelpBox("no Vehicles in Cloud Library or Assets/External/Vehicles", MessageType.Info); } } } } NPCSelectEnable = EditorGUILayout.BeginToggleGroup("NPC Select", NPCSelectEnable); if (NPCSelectEnable) { EditorGUI.indentLevel++; EditorGUILayout.BeginHorizontal(GUILayout.ExpandHeight(false)); if (GUILayout.Button("Select All", GUILayout.ExpandWidth(false))) { foreach (var npc in DeveloperSimulation.NPCs) { npc.Enabled = true; } } if (GUILayout.Button("Select None", GUILayout.ExpandWidth(false))) { foreach (var npc in DeveloperSimulation.NPCs) { npc.Enabled = false; } } EditorGUILayout.EndHorizontal(); foreach (var npc in DeveloperSimulation.NPCs) { npc.Enabled = EditorGUILayout.Toggle($"{npc.Name}", npc.Enabled); } EditorGUI.indentLevel--; } EditorGUILayout.EndToggleGroup(); EditorGUILayout.EndScrollView(); if (EditorGUI.EndChangeCheck()) { SaveAssetTime = Time.realtimeSinceStartup + 3.0f; } }
public void OnGUI() { if (Settings.guiIsActive && !isHideUI) { GUI.skin = HighLogic.Skin; // on showConfigs changed: resize window, save config if (Settings.showConfigs != showConfigs) { Settings.guiwindowPosition.height = 50; Settings.showConfigs = showConfigs; Settings.SaveToXml(); } // on vessel type changed: resize window if (vesselType != Gpws.ActiveVesselType) { Settings.guiwindowPosition.height = 50; } // draw Settings.guiwindowPosition = ClickThruBlocker.GUILayoutWindow("GPWSSetting".GetHashCode(), Settings.guiwindowPosition, WindowFunc, "GPWS Setting", GUILayout.ExpandHeight(true)); } }
private void DrawProfileSettings() { if (ScienceAlertProfileManager.HasActiveProfile) { GUILayout.BeginHorizontal(); GUILayout.Box($"Profile: {ScienceAlertProfileManager.ActiveProfile.DisplayName}", GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true)); if (AudibleButton(new GUIContent(renameButton), GUILayout.MaxWidth(24f))) { SpawnRenamePopup(ScienceAlertProfileManager.ActiveProfile); } GUI.enabled = ScienceAlertProfileManager.ActiveProfile.modified; if (AudibleButton(new GUIContent(saveButton), GUILayout.MaxWidth(24f))) { SpawnSavePopup(); } GUI.enabled = true; if (AudibleButton(new GUIContent(openButton), GUILayout.MaxWidth(24f))) { submenu = OpenPane.LoadProfiles; } GUILayout.EndHorizontal(); scrollPos = GUILayout.BeginScrollView(scrollPos, Settings.Skin.scrollView); GUI.skin = Settings.Skin; GUILayout.Space(4f); GUI.SetNextControlName("ThresholdHeader"); GUILayout.Box("Alert Threshold"); GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true), GUILayout.MinHeight(14f)); if (ScienceAlertProfileManager.ActiveProfile.ScienceThreshold > 0f) { GUILayout.Label( $"Alert Threshold: {ScienceAlertProfileManager.ActiveProfile.ScienceThreshold.ToString("F2", formatter)}"); } else { Color color = GUI.color; GUI.color = XKCDColors.Salmon; GUILayout.Label("(disabled)"); GUI.color = color; } GUILayout.FlexibleSpace(); if (string.IsNullOrEmpty(thresholdValue)) { thresholdValue = ScienceAlertProfileManager.ActiveProfile.scienceThreshold.ToString("F2", formatter); } GUI.SetNextControlName("ThresholdText"); string s = GUILayout.TextField(thresholdValue, GUILayout.MinWidth(60f)); if (Event.current.keyCode == KeyCode.Escape) { GUI.FocusControl("ThresholdHeader"); } if (GUI.GetNameOfFocusedControl() == "ThresholdText") { try { float scienceThreshold = float.Parse(s, formatter); ScienceAlertProfileManager.ActiveProfile.ScienceThreshold = scienceThreshold; thresholdValue = s; } catch (System.Exception) { // ignored } if (!InputLockManager.IsLocked(ControlTypes.ACTIONS_ALL)) { InputLockManager.SetControlLock(ControlTypes.ACTIONS_ALL, "ScienceAlertThreshold"); } } else if (InputLockManager.GetControlLock("ScienceAlertThreshold") != ControlTypes.None) { InputLockManager.RemoveControlLock("ScienceAlertThreshold"); } GUILayout.EndHorizontal(); GUILayout.Space(3f); var num = GUILayout.HorizontalSlider(ScienceAlertProfileManager.ActiveProfile.ScienceThreshold, 0f, 100f, GUILayout.ExpandWidth(true), GUILayout.Height(14f)); if (num != ScienceAlertProfileManager.ActiveProfile.scienceThreshold) { ScienceAlertProfileManager.ActiveProfile.ScienceThreshold = num; thresholdValue = num.ToString("F2", formatter); } GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true), GUILayout.MaxHeight(10f)); GUILayout.Label("0", miniLabelLeft); GUILayout.FlexibleSpace(); GUILayout.Label("Science Amount", miniLabelCenter); GUILayout.FlexibleSpace(); GUILayout.Label("100", miniLabelRight); GUILayout.EndHorizontal(); GUILayout.Space(10f); List <string> list = new List <string>(experimentIds.Keys); foreach (string current in list) { GUILayout.Space(4f); ExperimentSettings experimentSettings = ScienceAlertProfileManager.ActiveProfile[current]; string experimentTitle = ResearchAndDevelopment.GetExperiment(current).experimentTitle; GUILayout.Box(experimentTitle, GUILayout.ExpandWidth(true)); experimentSettings.Enabled = AudibleToggle(experimentSettings.Enabled, "Enabled"); experimentSettings.AnimationOnDiscovery = AudibleToggle(experimentSettings.AnimationOnDiscovery, "Animation on discovery"); experimentSettings.SoundOnDiscovery = AudibleToggle(experimentSettings.SoundOnDiscovery, "Sound on discovery"); experimentSettings.StopWarpOnDiscovery = AudibleToggle(experimentSettings.StopWarpOnDiscovery, "Stop warp on discovery"); GUILayout.Label(new GUIContent("Filter Method"), GUILayout.ExpandWidth(true), GUILayout.MinHeight(24f)); int num2 = experimentIds[current]; experimentIds[current] = AudibleSelectionGrid(num2, ref experimentSettings); } GUILayout.EndScrollView(); return; } GUI.color = Color.red; GUILayout.Label("No profile active"); }
void OnGUI() { GUILayout.Space(8); GUILayout.Label("TheMatrix Tool of Minstreams", "WarningOverlay"); GUILayout.Space(8); GUILayout.BeginVertical("GameViewBackground", GUILayout.ExpandHeight(true)); SectionHeader("数据导航 Data Navigation"); if (Button("System Setting")) { NavToSystemConfig(); } if (Button("Editor Setting")) { Selection.activeObject = TheMatrix.EditorSetting; } SeparatorSmall(); if (subSystemSettings != null) { for (int i = 0; i < subSystemSettings.Length; ++i) { int start = Mathf.Max(subSystemSettings[i].LastIndexOf('/') + 1, 0); string subName = subSystemSettings[i].Substring(start, subSystemSettings[i].Length - start - 19); if (GUILayout.Button(subName, BtnStyle)) { Selection.activeObject = AssetDatabase.LoadAssetAtPath <Object>(subSystemSettings[i]); subSystemName = subName; subSystemComment = ""; } } } SeparatorSmall(); if (Button("刷新")) { ScanSubSystem(); } SectionHeader("自动测试 Auto Test"); if (Button("测试全部场景")) { DebugAll(); } if (Button("测试当前场景")) { DebugCurrent(); } SectionHeader("自动化代码生成 Code Generation"); GUILayout.BeginHorizontal(TabBGStyle); { if (GUILayout.Button("SubSystem", editorMode == EditorMode.SubSystem ? TabLabelStyle : TabStyle)) { editorMode = EditorMode.SubSystem; } if (GUILayout.Button("Linker", editorMode == EditorMode.Linker ? TabLabelStyle : TabStyle)) { editorMode = EditorMode.Linker; } if (GUILayout.Button("Operator", editorMode == EditorMode.Operator ? TabLabelStyle : TabStyle)) { editorMode = EditorMode.Operator; } if (GUILayout.Button("Savable", editorMode == EditorMode.Savable ? TabLabelStyle : TabStyle)) { editorMode = EditorMode.Savable; } if (GUILayout.Button("UI", editorMode == EditorMode.UI ? TabLabelStyle : TabStyle)) { editorMode = EditorMode.UI; } } GUILayout.EndHorizontal(); GUILayout.Space(4); switch (editorMode) { case EditorMode.SubSystem: subSystemName = TextArea("Sub System Name", subSystemName); subSystemComment = TextArea("Comment", subSystemComment, 64); Label("自动生成一个子系统 Sub System"); Label("由于实在无法把生成代码与生成配置文件功能做到一起,生成新系统时,请依次点这两个按钮。"); if (Button("Add")) { AddSubSystem(subSystemName, subSystemComment); } if (Button("Create Setting Asset")) { CreateSettingAsset(); ScanSubSystem(); } break; case EditorMode.Linker: EditorGUI.BeginChangeCheck(); linkerName = TextArea("Linker Name", linkerName); if (EditorGUI.EndChangeCheck()) { linkerTitle = linkerName; } linkerTitle = TextArea("Linker Title", linkerTitle); linkerComment = TextArea("Comment", linkerComment, 64); Label("自动生成一个连接节点 Linker,用于连接和处理数据。"); if (Button("Add")) { AddLinker(linkerName, linkerTitle, linkerComment); } if (Button("Add To Current SubSystem")) { if (string.IsNullOrWhiteSpace(subSystemName)) { EditorUtility.DisplayDialog(DialogTitle, "请先在‘数据导航’一栏中选择子系统", "好的"); } else { AddLinker(linkerName, linkerTitle, linkerComment, subSystemName); } } break; case EditorMode.Operator: EditorGUI.BeginChangeCheck(); operatorName = TextArea("Operator Name", operatorName); if (EditorGUI.EndChangeCheck()) { operatorTitle = operatorName; } operatorTitle = TextArea("Operator Title", operatorTitle); operatorComment = TextArea("Comment", operatorComment, 64); Label("自动生成一个操作节点 Operator,用于执行具体动作。"); if (Button("Add")) { AddOperator(operatorName, operatorTitle, operatorComment); } if (Button("Add To Current SubSystem")) { if (string.IsNullOrWhiteSpace(subSystemName)) { EditorUtility.DisplayDialog(DialogTitle, "请先在‘数据导航’一栏中选择子系统", "好的"); } else { AddOperator(operatorName, operatorTitle, operatorComment, subSystemName); } } break; case EditorMode.Savable: EditorGUI.BeginChangeCheck(); savableName = TextArea("Savable Name", savableName); if (EditorGUI.EndChangeCheck()) { savableTitle = savableName; } savableTitle = TextArea("Savable Title", savableTitle); savableComment = TextArea("Comment", savableComment, 64); Label("自动生成一个可存储对象SavableObject,用于持久化存储数据。"); if (Button("Add")) { AddSavable(savableName, savableTitle, savableComment); } if (Button("Add To Current SubSystem")) { if (string.IsNullOrWhiteSpace(subSystemName)) { EditorUtility.DisplayDialog(DialogTitle, "请先在‘数据导航’一栏中选择子系统", "好的"); } else { AddSavable(savableName, savableTitle, savableComment, subSystemName); } } break; case EditorMode.UI: EditorGUI.BeginChangeCheck(); uiName = TextArea("UI Name", uiName); if (EditorGUI.EndChangeCheck()) { uiTitle = uiName; } uiTitle = TextArea("UI Title", uiTitle); uiComment = TextArea("Comment", uiComment, 64); Label("自动生成一个UI组件。"); if (Button("Add")) { AddUI(uiName, uiTitle, uiComment); } if (Button("Add To Current SubSystem")) { if (string.IsNullOrWhiteSpace(subSystemName)) { EditorUtility.DisplayDialog(DialogTitle, "请先在‘数据导航’一栏中选择子系统", "好的"); } else { AddUI(uiName, uiTitle, uiComment, subSystemName); } } break; } Separator(); GUILayout.EndVertical(); }