void OnGUI() { //*************** scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.Width(0), GUILayout.Height(0)); //*************** GUIStyle style = new GUIStyle(GUI.skin.label); style.richText = true; if (materials == null) { materials = new List <Material>(); } //Status - Anything Compiling GUILayout.Label("Status", EditorStyles.boldLabel); anythingCompiling = ShaderUtil.anythingCompiling; GUI.color = anythingCompiling? Color.magenta : Color.green; GUILayout.Label("Anything compiling : " + anythingCompiling); GUI.color = Color.white; GUILayout.Space(10); //General settings - Allow Async Compilation GUILayout.Label("General", EditorStyles.boldLabel); allowAsyncCompilation = EditorGUILayout.Toggle("Allow Async Compilation?", allowAsyncCompilation); GUILayout.Space(10); //Set Material settings - Force Sync / Pass Index / isPassCompiled GUILayout.Label("Per Material", EditorStyles.boldLabel); forceSync = EditorGUILayout.Toggle("Force sync?", forceSync); //passIndexMax = EditorGUILayout.IntField("Pass Index Max.",passIndexMax); //Buttons GUILayout.Space(10); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Update Selection")) { UpdateSelection(); } if (GUILayout.Button("Update & Compile all passes")) { Apply(); } EditorGUILayout.EndHorizontal(); //Show selected material GUILayout.Label("Materials:", EditorStyles.boldLabel); if (materials.Count <= 0) { GUI.color = Color.cyan; GUILayout.Label("Select material(s) in ProjectView and click Update Selection"); GUI.color = Color.white; } else { GUI.color = Color.cyan; GUILayout.Label("Selected " + materials.Count + " material(s)"); GUI.color = Color.white; } //Material list header EditorGUILayout.BeginHorizontal(); GUILayout.Label("Id", style); GUILayout.Label("Material Name", style); GUILayout.Label("Pass compilation status", style); EditorGUILayout.EndHorizontal(); //Display each selected material isPassCompiled status for (int i = 0; i < materials.Count; i++) { if (materials[i] != null) { EditorGUILayout.BeginHorizontal(); //id GUILayout.Label(i.ToString(), style); //name GUILayout.Label("<color=#0ff>" + materials[i].name + "</Color>", style); //status string text = ""; for (int j = 0; j < materials[i].passCount; j++) { if (ShaderUtil.IsPassCompiled(materials[i], j)) { text += "<color=#0f0>Y</Color>"; } else { text += "<color=#f0f>N</Color>"; } } GUILayout.Label(text, style); EditorGUILayout.EndHorizontal(); } } //Gap GUILayout.Space(15); //*************** GUILayout.EndScrollView(); //*************** }
public void OnGUI() { GUIStyle link = new GUIStyle(GUI.skin.label); link.normal.textColor = new Color(.7f, .7f, 1f); // Title GUILayout.BeginVertical(); GUILayout.Space(10); GUILayout.Label(GPGSStrings.IOSSetup.Blurb); GUILayout.Space(10); if (GUILayout.Button("Open Play Games Console", link, GUILayout.ExpandWidth(false))) { Application.OpenURL("https://play.google.com/apps/publish"); } Rect last = GUILayoutUtility.GetLastRect(); last.y += last.height - 2; last.x += 3; last.width -= 6; last.height = 2; GUI.Box(last, string.Empty); GUILayout.Space(15); // Bundle ID field GUILayout.Label(GPGSStrings.IOSSetup.BundleIdTitle, EditorStyles.boldLabel); GUILayout.Label(GPGSStrings.IOSSetup.BundleIdBlurb, EditorStyles.wordWrappedLabel); mBundleId = EditorGUILayout.TextField(GPGSStrings.IOSSetup.BundleId, mBundleId, GUILayout.Width(450)); GUILayout.Space(30); // Requires G+ field GUILayout.BeginHorizontal(); GUILayout.Label(GPGSStrings.Setup.RequiresGPlusTitle, EditorStyles.boldLabel); mRequiresGooglePlus = EditorGUILayout.Toggle(mRequiresGooglePlus); GUILayout.EndHorizontal(); GUILayout.Label(GPGSStrings.Setup.RequiresGPlusBlurb); // Client ID field GUILayout.Label(GPGSStrings.Setup.WebClientIdTitle, EditorStyles.boldLabel); GUILayout.Label(GPGSStrings.AndroidSetup.WebClientIdBlurb, EditorStyles.wordWrappedLabel); GUILayout.Space(10); mWebClientId = EditorGUILayout.TextField(GPGSStrings.Setup.ClientId, mWebClientId, GUILayout.Width(450)); GUILayout.Space(10); GUILayout.FlexibleSpace(); GUILayout.Label("Constants class name", EditorStyles.boldLabel); GUILayout.Label("Enter the fully qualified name of the class to create containing the constants"); GUILayout.Space(10); mClassDirectory = EditorGUILayout.TextField("Directory to save constants", mClassDirectory, GUILayout.Width(480)); mClassName = EditorGUILayout.TextField("Constants class name", mClassName, GUILayout.Width(480)); GUILayout.Label("Resources Definition", EditorStyles.boldLabel); GUILayout.Label("Paste in the Objective-C Resources from the Play Console"); GUILayout.Space(10); scroll = GUILayout.BeginScrollView(scroll); mConfigData = EditorGUILayout.TextArea(mConfigData, GUILayout.Width(475), GUILayout.Height(Screen.height)); GUILayout.EndScrollView(); GUILayout.Space(10); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); // Setup button if (GUILayout.Button(GPGSStrings.Setup.SetupButton)) { // check that the classname entered is valid try { if (GPGSUtil.LooksLikeValidPackageName(mClassName)) { DoSetup(); } } catch (Exception e) { GPGSUtil.Alert(GPGSStrings.Error, "Invalid classname: " + e.Message); } } if (GUILayout.Button(GPGSStrings.Cancel)) { this.Close(); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(20); GUILayout.EndVertical(); }
private void OnGUI() { GUILayout.BeginVertical(string.Empty, "Window"); #region Select Directory GUILayout.BeginHorizontal(); GUILayout.Label("Target Directory", GUILayout.Width(labelWidth)); targetDirectory = GUILayout.TextField(targetDirectory); if (GUILayout.Button("Browse", GUILayout.Width(buttonWidth))) { SelectDirectory(); } GUILayout.EndHorizontal(); #endregion #region Pattern Settings GUILayout.BeginHorizontal(); GUILayout.Label("Pattern Settings", GUILayout.Width(labelWidth)); EditorGUI.BeginChangeCheck(); patternSettings = EditorGUILayout.ObjectField(patternSettings, typeof(AssetPatternSettings), false) as AssetPatternSettings; if (EditorGUI.EndChangeCheck()) { ClearEditorCache(); } if (GUILayout.Button("New", GUILayout.Width(buttonWidth))) { CreateNewSettings(); } GUILayout.EndHorizontal(); #endregion #region Top Tool Bar GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Check", GUILayout.Width(buttonWidth))) { CheckAssetsName(); } if (GUILayout.Button("Clear", GUILayout.Width(buttonWidth))) { ClearEditorCache(); } GUILayout.EndHorizontal(); #endregion #region Mismatch Assets GUILayout.BeginHorizontal(); GUILayout.Label("Mismatch Assets", GUILayout.Width(labelWidth)); GUILayout.Label(filterAssets.Count.ToString()); GUILayout.EndHorizontal(); scrollPos = GUILayout.BeginScrollView(scrollPos, "Box"); var startIndex = pageIndex * eachPageCount; var limitCount = Math.Min(eachPageCount, filterAssets.Count - startIndex); for (int i = startIndex; i < startIndex + limitCount; i++) { if (GUILayout.Button(filterAssets[i], "TextField")) { Selection.activeObject = AssetDatabase.LoadAssetAtPath(filterAssets[i], typeof(UnityEngine.Object)); } } GUILayout.EndScrollView(); #endregion #region Bottom Tool Bar if (pageCount > 1) { GUILayout.BeginHorizontal(); if (pageIndex > 0) { if (GUILayout.Button("Previous", GUILayout.Width(buttonWidth))) { pageIndex--; scrollPos = Vector2.zero; } } else { GUILayout.Label(string.Empty, GUILayout.Width(buttonWidth)); } GUILayout.FlexibleSpace(); GUILayout.Label(pageIndex + 1 + " / " + pageCount); GUILayout.FlexibleSpace(); if (pageIndex < pageCount - 1) { if (GUILayout.Button("Next", GUILayout.Width(buttonWidth))) { pageIndex++; scrollPos = Vector2.zero; } } else { GUILayout.Label(string.Empty, GUILayout.Width(buttonWidth)); } GUILayout.EndHorizontal(); } #endregion GUILayout.EndVertical(); }
public void Draw(bool drawCodeExample) { if (exampleGroupStyle == null) { exampleGroupStyle = new GUIStyle(GUIStyle.none) { padding = new RectOffset(1, 1, 10, 0) }; } if (previewStyle == null) { previewStyle = new GUIStyle(GUIStyle.none) { padding = new RectOffset(0, 0, 0, 0), }; } GUILayout.BeginVertical(exampleGroupStyle); if (this.ExampleInfo.Description != null) { SirenixEditorGUI.BeginBox(); GUILayout.BeginHorizontal(); GUILayout.Space(23); GUILayout.Label(this.ExampleInfo.Description, SirenixGUIStyles.MultiLineLabel); var rect = GUILayoutUtility.GetLastRect(); EditorIcons.X.Draw(rect.SubX(26).SetWidth(26).AlignCenterXY(20), EditorIcons.Info.Active); GUILayout.EndHorizontal(); SirenixEditorGUI.EndBox(); GUILayout.Space(12); } GUILayout.Label("Interactive Preview", SirenixGUIStyles.BoldTitle); GUILayout.BeginVertical(previewStyle, GUILayoutOptions.ExpandWidth(true)); { Rect rect = GUIHelper.GetCurrentLayoutRect().Expand(4, 0); SirenixEditorGUI.DrawSolidRect(rect, EditorGUIUtility.isProSkin ? previewBackgroundColorDark : previewBackgroundColorLight); SirenixEditorGUI.DrawBorders(rect, 1); GUILayout.Space(8); this.tree = this.tree ?? PropertyTree.Create(this.ExampleInfo.PreviewObject); this.tree.Draw(false); GUILayout.Space(8); } GUILayout.EndVertical(); if (drawCodeExample && this.ExampleInfo.Code != null) { GUILayout.Space(12); GUILayout.Label("Code", SirenixGUIStyles.BoldTitle); Rect rect = SirenixEditorGUI.BeginToolbarBox(); SirenixEditorGUI.DrawSolidRect(rect.HorizontalPadding(1), SyntaxHighlighter.BackgroundColor); SirenixEditorGUI.BeginToolbarBoxHeader(); { if (SirenixEditorGUI.ToolbarButton(this.showRaw ? "Highlighted" : "Raw")) { this.showRaw = !this.showRaw; } GUILayout.FlexibleSpace(); if (SirenixEditorGUI.ToolbarButton("Copy")) { Clipboard.Copy(this.ExampleInfo.Code); } } SirenixEditorGUI.EndToolbarBoxHeader(); if (codeTextStyle == null) { codeTextStyle = new GUIStyle(SirenixGUIStyles.MultiLineLabel); codeTextStyle.normal.textColor = SyntaxHighlighter.TextColor; codeTextStyle.active.textColor = SyntaxHighlighter.TextColor; codeTextStyle.focused.textColor = SyntaxHighlighter.TextColor; codeTextStyle.wordWrap = false; } GUIContent codeContent = GUIHelper.TempContent(this.showRaw ? this.ExampleInfo.Code.TrimEnd('\n', '\r') : this.highlightedCode); Vector2 size = codeTextStyle.CalcSize(codeContent); GUILayout.BeginHorizontal(); GUILayout.Space(-3); GUILayout.BeginVertical(); { GUIHelper.PushEventType(Event.current.type == EventType.ScrollWheel ? EventType.Used : Event.current.type); // Prevent the code horizontal scroll view from eating the scroll event. this.scrollPosition = GUILayout.BeginScrollView(this.scrollPosition, true, false, GUI.skin.horizontalScrollbar, GUIStyle.none, GUILayout.MinHeight(size.y + 20)); var codeRect = GUILayoutUtility.GetRect(size.x + 50, size.y).AddXMin(4).AddY(2); if (this.showRaw) { EditorGUI.SelectableLabel(codeRect, this.ExampleInfo.Code, codeTextStyle); GUILayout.Space(-14); } else { GUI.Label(codeRect, codeContent, codeTextStyle); } GUILayout.EndScrollView(); GUIHelper.PopEventType(); } GUILayout.EndVertical(); GUILayout.Space(-3); GUILayout.EndHorizontal(); GUILayout.Space(-3); SirenixEditorGUI.EndToolbarBox(); } GUILayout.EndVertical(); }
private void DrawContent(int windowID) { GUILayout.BeginVertical(); GUI.DragWindow(moveRect); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUIStyle chatButtonStyle = buttonStyle; if (ChatWorker.fetch.chatButtonHighlighted) { chatButtonStyle = highlightStyle; } ChatWorker.fetch.display = GUILayout.Toggle(ChatWorker.fetch.display, "Chat", chatButtonStyle); CraftLibraryWorker.fetch.display = GUILayout.Toggle(CraftLibraryWorker.fetch.display, "Craft", buttonStyle); DebugWindow.fetch.display = GUILayout.Toggle(DebugWindow.fetch.display, "Debug", buttonStyle); GUIStyle screenshotButtonStyle = buttonStyle; if (ScreenshotWorker.fetch.screenshotButtonHighlighted) { screenshotButtonStyle = highlightStyle; } ScreenshotWorker.fetch.display = GUILayout.Toggle(ScreenshotWorker.fetch.display, "Screenshot", screenshotButtonStyle); if (GUILayout.Button("-", buttonStyle)) { minmized = true; minWindowRect.x = windowRect.xMax - minWindowRect.width; minWindowRect.y = windowRect.y; } GUILayout.EndHorizontal(); scrollPosition = GUILayout.BeginScrollView(scrollPosition, scrollStyle); //Draw subspaces double ourTime = TimeSyncer.fetch.locked ? TimeSyncer.fetch.GetUniverseTime() : Planetarium.GetUniversalTime(); long serverClock = TimeSyncer.fetch.GetServerClock(); foreach (SubspaceDisplayEntry currentEntry in subspaceDisplay) { double currentTime = 0; double diffTime = 0; string diffState = "Unknown"; if (!currentEntry.isUs) { if (!currentEntry.isWarping) { //Subspace entry if (currentEntry.subspaceEntry != null) { long serverClockDiff = serverClock - currentEntry.subspaceEntry.serverClock; double secondsDiff = serverClockDiff / 10000000d; currentTime = currentEntry.subspaceEntry.planetTime + (currentEntry.subspaceEntry.subspaceSpeed * secondsDiff); diffTime = currentTime - ourTime; diffState = (diffTime > 0) ? SecondsToVeryShortString((int)diffTime) + " in the future" : SecondsToVeryShortString(-(int)diffTime) + " in the past"; } } else { //Warp entry if (currentEntry.warpingEntry != null) { float[] warpRates = TimeWarp.fetch.warpRates; if (currentEntry.warpingEntry.isPhysWarp) { warpRates = TimeWarp.fetch.physicsWarpRates; } long serverClockDiff = serverClock - currentEntry.warpingEntry.serverClock; double secondsDiff = serverClockDiff / 10000000d; currentTime = currentEntry.warpingEntry.planetTime + (warpRates[currentEntry.warpingEntry.rateIndex] * secondsDiff); diffTime = currentTime - ourTime; diffState = (diffTime > 0) ? SecondsToVeryShortString((int)diffTime) + " in the future" : SecondsToVeryShortString(-(int)diffTime) + " in the past"; } } } else { currentTime = ourTime; diffState = "NOW"; } //Draw the subspace black bar. GUILayout.BeginHorizontal(subspaceStyle); GUILayout.Label("T+ " + SecondsToShortString((int)currentTime) + " - " + diffState); GUILayout.FlexibleSpace(); //Draw the sync button if needed if ((WarpWorker.fetch.warpMode == WarpMode.SUBSPACE) && !currentEntry.isUs && !currentEntry.isWarping && (currentEntry.subspaceEntry != null) && (diffTime > 0)) { if (GUILayout.Button("Sync", buttonStyle)) { TimeSyncer.fetch.LockSubspace(currentEntry.subspaceID); } } GUILayout.EndHorizontal(); foreach (string currentPlayer in currentEntry.players) { if (currentPlayer == Settings.fetch.playerName) { DrawPlayerEntry(PlayerStatusWorker.fetch.myPlayerStatus); } else { DrawPlayerEntry(PlayerStatusWorker.fetch.GetPlayerStatus(currentPlayer)); } } } GUILayout.EndScrollView(); GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Disconnect", buttonStyle)) { disconnectEventHandled = false; } OptionsWindow.fetch.display = GUILayout.Toggle(OptionsWindow.fetch.display, "Options", buttonStyle); GUILayout.EndHorizontal(); GUILayout.EndVertical(); }
public override void DrawGUI(Rect position, BuildInfo buildReportToDisplay) { GUILayout.Space(10); // extra top padding _assetListScrollPos = GUILayout.BeginScrollView(_assetListScrollPos); GUILayout.BeginHorizontal(); GUILayout.Space(20); // extra left padding GUILayout.BeginVertical(); if (!string.IsNullOrEmpty(BuildReportTool.Options.FoundPathForSavedOptions)) { GUILayout.BeginHorizontal(BuildReportTool.Window.Settings.BOXED_LABEL_STYLE_NAME); GUILayout.Label(string.Format("Using options file in: {0}", BuildReportTool.Options.FoundPathForSavedOptions)); GUILayout.FlexibleSpace(); if (GUILayout.Button("Reload")) { BuildReportTool.Options.RefreshOptions(); } GUILayout.EndHorizontal(); GUILayout.Space(10); } // === Main Options === GUILayout.Label("Main Options", BuildReportTool.Window.Settings.INFO_TITLE_STYLE_NAME); BuildReportTool.Options.CollectBuildInfo = GUILayout.Toggle(BuildReportTool.Options.CollectBuildInfo, Labels.COLLECT_BUILD_INFO_LABEL); BuildReportTool.Options.AllowDeletingOfUsedAssets = GUILayout.Toggle(BuildReportTool.Options.AllowDeletingOfUsedAssets, "Allow deleting of Used Assets (practice caution!)"); GUILayout.Space(10); BuildReportTool.Options.IncludeBuildSizeInReportCreation = GUILayout.Toggle(BuildReportTool.Options.IncludeBuildSizeInReportCreation, "Get build's file size upon creation of a build report"); BuildReportTool.Options.GetImportedSizesForUsedAssets = GUILayout.Toggle(BuildReportTool.Options.GetImportedSizesForUsedAssets, "Get imported sizes of Used Assets upon creation of a build report"); BuildReportTool.Options.GetImportedSizesForUnusedAssets = GUILayout.Toggle(BuildReportTool.Options.GetImportedSizesForUnusedAssets, "Get imported sizes of Unused Assets upon creation of a build report"); BuildReportTool.Options.GetProjectSettings = GUILayout.Toggle(BuildReportTool.Options.GetProjectSettings, "Get Unity project settings upon creation of a build report"); GUILayout.Space(10); GUILayout.BeginHorizontal(); GUILayout.Label("Automatically show Build Report Window after building: "); GUILayout.BeginVertical(); int newSelectedAutoShowWindowIdx = EditorGUILayout.Popup(_selectedAutoShowWindowIdx, _autoShowWindowLabels, "Popup", GUILayout.Width(300)); GUILayout.EndVertical(); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); if (newSelectedAutoShowWindowIdx != _selectedAutoShowWindowIdx) { _selectedAutoShowWindowIdx = newSelectedAutoShowWindowIdx; SetAutoShowWindowTypeFromGuiIdx(newSelectedAutoShowWindowIdx); } GUILayout.Space(10); GUILayout.BeginHorizontal(); GUILayout.Label("Calculation Level: "); GUILayout.BeginVertical(); int newSelectedCalculationLevelIdx = EditorGUILayout.Popup(_selectedCalculationLevelIdx, _calculationTypeLabels, "Popup", GUILayout.Width(300)); GUILayout.BeginHorizontal(); GUILayout.Space(20); GUILayout.Label(CalculationLevelDescription, GUILayout.MaxWidth(500), GUILayout.MinHeight(75)); GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(BuildReportTool.Window.Settings.CATEGORY_VERTICAL_SPACING); if (newSelectedCalculationLevelIdx != _selectedCalculationLevelIdx) { _selectedCalculationLevelIdx = newSelectedCalculationLevelIdx; SetCalculationLevelFromGuiIdx(newSelectedCalculationLevelIdx); } // === Editor Log File === GUILayout.Label("Editor Log File", BuildReportTool.Window.Settings.INFO_TITLE_STYLE_NAME); // which Editor.log is used GUILayout.BeginHorizontal(); GUILayout.Label(Labels.EDITOR_LOG_LABEL + BuildReportTool.Util.EditorLogPathOverrideMessage + ": " + BuildReportTool.Util.UsedEditorLogPath); if (GUILayout.Button(OPEN_IN_FILE_BROWSER_OS_SPECIFIC_LABEL) && BuildReportTool.Util.UsedEditorLogExists) { BuildReportTool.Util.OpenInFileBrowser(BuildReportTool.Util.UsedEditorLogPath); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); if (!BuildReportTool.Util.UsedEditorLogExists) { GUILayout.Label(Labels.EDITOR_LOG_INVALID_MSG); } // override which log is opened GUILayout.BeginHorizontal(); if (GUILayout.Button(Labels.SET_OVERRIDE_LOG_LABEL)) { string filepath = EditorUtility.OpenFilePanel( "", // title "", // default path ""); // file type (only one type allowed?) if (!string.IsNullOrEmpty(filepath)) { BuildReportTool.Options.EditorLogOverridePath = filepath; } } if (GUILayout.Button(Labels.CLEAR_OVERRIDE_LOG_LABEL)) { BuildReportTool.Options.EditorLogOverridePath = ""; } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(BuildReportTool.Window.Settings.CATEGORY_VERTICAL_SPACING); // === Asset Lists === GUILayout.Label("Asset Lists", BuildReportTool.Window.Settings.INFO_TITLE_STYLE_NAME); BuildReportTool.Options.IncludeSvnInUnused = GUILayout.Toggle(BuildReportTool.Options.IncludeSvnInUnused, Labels.INCLUDE_SVN_LABEL); BuildReportTool.Options.IncludeGitInUnused = GUILayout.Toggle(BuildReportTool.Options.IncludeGitInUnused, Labels.INCLUDE_GIT_LABEL); GUILayout.Space(10); // pagination length GUILayout.BeginHorizontal(); GUILayout.Label("View assets per groups of:"); string pageInput = GUILayout.TextField(BuildReportTool.Options.AssetListPaginationLength.ToString(), GUILayout.MinWidth(100)); pageInput = Regex.Replace(pageInput, @"[^0-9]", ""); // positive numbers only, no fractions if (string.IsNullOrEmpty(pageInput)) { pageInput = "0"; } BuildReportTool.Options.AssetListPaginationLength = int.Parse(pageInput); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(10); // unused assets entries per batch GUILayout.BeginHorizontal(); GUILayout.Label("Process unused assets per batches of:"); string entriesPerBatchInput = GUILayout.TextField(BuildReportTool.Options.UnusedAssetsEntriesPerBatch.ToString(), GUILayout.MinWidth(100)); entriesPerBatchInput = Regex.Replace(entriesPerBatchInput, @"[^0-9]", ""); // positive numbers only, no fractions if (string.IsNullOrEmpty(entriesPerBatchInput)) { entriesPerBatchInput = "0"; } BuildReportTool.Options.UnusedAssetsEntriesPerBatch = int.Parse(entriesPerBatchInput); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(10); // choose which file filter group to use GUILayout.BeginHorizontal(); GUILayout.Label(Labels.FILTER_GROUP_TO_USE_LABEL); BuildReportTool.Options.FilterToUseInt = GUILayout.SelectionGrid(BuildReportTool.Options.FilterToUseInt, _fileFilterToUseType, _fileFilterToUseType.Length); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); // display which file filter group is used GUILayout.BeginHorizontal(); GUILayout.Label(Labels.FILTER_GROUP_FILE_PATH_LABEL + BuildReportTool.FiltersUsed.GetProperFileFilterGroupToUseFilePath()); // display path to used file filter if (GUILayout.Button(OPEN_IN_FILE_BROWSER_OS_SPECIFIC_LABEL)) { BuildReportTool.Util.OpenInFileBrowser(BuildReportTool.FiltersUsed.GetProperFileFilterGroupToUseFilePath()); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(BuildReportTool.Window.Settings.CATEGORY_VERTICAL_SPACING); // === Build Report Files === GUILayout.Label("Build Report Files", BuildReportTool.Window.Settings.INFO_TITLE_STYLE_NAME); // build report files save path GUILayout.BeginHorizontal(); GUILayout.Label(Labels.SAVE_PATH_LABEL + BuildReportTool.Options.BuildReportSavePath); if (GUILayout.Button(OPEN_IN_FILE_BROWSER_OS_SPECIFIC_LABEL)) { BuildReportTool.Util.OpenInFileBrowser(BuildReportTool.Options.BuildReportSavePath); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); // change name of build reports folder GUILayout.BeginHorizontal(); GUILayout.Label(Labels.SAVE_FOLDER_NAME_LABEL); BuildReportTool.Options.BuildReportFolderName = GUILayout.TextField(BuildReportTool.Options.BuildReportFolderName, GUILayout.MinWidth(250)); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); // where to save build reports (my docs/home, or beside project) GUILayout.BeginHorizontal(); GUILayout.Label(Labels.SAVE_PATH_TYPE_LABEL); BuildReportTool.Options.SaveType = GUILayout.SelectionGrid(BuildReportTool.Options.SaveType, _saveTypeLabels, _saveTypeLabels.Length); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(BuildReportTool.Window.Settings.CATEGORY_VERTICAL_SPACING); GUILayout.EndVertical(); GUILayout.Space(20); // extra right padding GUILayout.EndHorizontal(); GUILayout.EndScrollView(); //if (BuildReportTool.Options.SaveType == BuildReportTool.Options.SAVE_TYPE_PERSONAL) //{ // changed to user's personal folder //BuildReportTool.ReportGenerator.ChangeSavePathToUserPersonalFolder(); //} //else if (BuildReportTool.Options.SaveType == BuildReportTool.Options.SAVE_TYPE_PROJECT) //{ // changed to project folder //BuildReportTool.ReportGenerator.ChangeSavePathToProjectFolder(); //} }
private void OnGUI() { Rect rect = new Rect(0, 0, position.width, position.height); var e = Event.current; if (e.type == EventType.ContextClick) { if (rect.Contains(e.mousePosition)) { var menu = new GenericMenu(); menu.AddItem(new GUIContent("Delete Selected Brush"), false, this.DeleteSelectedBrush); menu.AddItem(new GUIContent("Delete All Brushes"), false, this.DeleteAllBrushes); menu.ShowAsContext(); e.Use(); } } if (e.type == EventType.DragUpdated || e.type == EventType.DragPerform) { if (rect.Contains(Event.current.mousePosition)) { DragAndDrop.visualMode = DragAndDropVisualMode.Link; //如果拖入了拖拽区 if (e.type == EventType.DragPerform) { DragAndDrop.AcceptDrag(); for (int i = 0; i < DragAndDrop.objectReferences.Length; i++) { var obj = DragAndDrop.objectReferences[i]; BlockBrush brush = new BlockBrush(obj.name); brush.prefab = DragAndDrop.paths[i]; brush.preview = AssetPreview.GetAssetPreview(obj); this.brushes.Add(brush); } this.selectedIndex = 0; BlockBrush.activeBrush = brushes[selectedIndex]; } } Event.current.Use(); } List <GUIContent> contents = new List <GUIContent>(); if (this.brushes.Count == 0) { EditorGUILayout.HelpBox("拖住Prefab到这里", MessageType.Info); } for (int i = 0; i < brushes.Count; i++) { if (brushes[i].preview == null) { GameObject go = AssetDatabase.LoadAssetAtPath <GameObject>(brushes[i].prefab); brushes[i].preview = AssetPreview.GetAssetPreview(go); } contents.Add(new GUIContent(brushes[i].preview)); } scrollPosition = GUILayout.BeginScrollView(scrollPosition); int xcount = Mathf.FloorToInt(rect.width / 64); int ycount = Mathf.CeilToInt(brushes.Count / xcount); int tempIndex = GUILayout.SelectionGrid(selectedIndex, contents.ToArray(), xcount, gridStyle, GUILayout.Width(64 * xcount), GUILayout.Height(64 * ycount)); if (tempIndex != selectedIndex) { selectedIndex = tempIndex; BlockBrush.activeBrush = brushes[selectedIndex]; } GUILayout.EndScrollView(); }
void OnGUI() { if (dict == null) { return; } mScroll = GUILayout.BeginScrollView(mScroll); List <string> list = dict["level"]; if (list != null && list.Count > 0) { if (DrawHeader("Level")) { foreach (string item in list) { SceneAsset go = AssetDatabase.LoadAssetAtPath(item, typeof(SceneAsset)) as SceneAsset; EditorGUILayout.ObjectField("Level:", go, typeof(SceneAsset), false); } } list = null; } list = dict["prefab"]; if (list != null && list.Count > 0) { if (DrawHeader("Prefab")) { foreach (string item in list) { GameObject go = AssetDatabase.LoadAssetAtPath(item, typeof(GameObject)) as GameObject; EditorGUILayout.ObjectField("Prefab", go, typeof(GameObject), false); } } list = null; } list = dict["fbx"]; if (list != null && list.Count > 0) { if (DrawHeader("FBX")) { foreach (string item in list) { GameObject go = AssetDatabase.LoadAssetAtPath(item, typeof(GameObject)) as GameObject; EditorGUILayout.ObjectField("FBX", go, typeof(GameObject), false); } } list = null; } list = dict["cs"]; if (list != null && list.Count > 0) { if (DrawHeader("Script")) { foreach (string item in list) { MonoScript go = AssetDatabase.LoadAssetAtPath(item, typeof(MonoScript)) as MonoScript; EditorGUILayout.ObjectField("Script", go, typeof(MonoScript), false); } } list = null; } list = dict["texture"]; if (list != null && list.Count > 0) { if (DrawHeader("Texture")) { foreach (string item in list) { Texture2D go = AssetDatabase.LoadAssetAtPath(item, typeof(Texture2D)) as Texture2D; EditorGUILayout.ObjectField("Texture:" + go.name, go, typeof(Texture2D), false); } } list = null; } list = dict["mat"]; if (list != null && list.Count > 0) { if (DrawHeader("Material")) { foreach (string item in list) { Material go = AssetDatabase.LoadAssetAtPath(item, typeof(Material)) as Material; EditorGUILayout.ObjectField("Material", go, typeof(Material), false); } } list = null; } list = dict["shader"]; if (list != null && list.Count > 0) { if (DrawHeader("Shader")) { foreach (string item in list) { Shader go = AssetDatabase.LoadAssetAtPath(item, typeof(Shader)) as Shader; EditorGUILayout.ObjectField("Shader", go, typeof(Shader), false); } } list = null; } list = dict["font"]; if (list != null && list.Count > 0) { if (DrawHeader("Font")) { foreach (string item in list) { Font go = AssetDatabase.LoadAssetAtPath(item, typeof(Font)) as Font; EditorGUILayout.ObjectField("Font", go, typeof(Font), false); } } list = null; } list = dict["anim"]; if (list != null && list.Count > 0) { if (DrawHeader("Animation")) { foreach (string item in list) { AnimationClip go = AssetDatabase.LoadAssetAtPath(item, typeof(AnimationClip)) as AnimationClip; EditorGUILayout.ObjectField("Animation:", go, typeof(AnimationClip), false); } } list = null; } list = dict["animTor"]; if (list != null && list.Count > 0) { if (DrawHeader("Animator")) { foreach (string item in list) { RuntimeAnimatorController go = AssetDatabase.LoadAssetAtPath(item, typeof(RuntimeAnimatorController)) as RuntimeAnimatorController; EditorGUILayout.ObjectField("Animator:", go, typeof(RuntimeAnimatorController), true); } } list = null; } GUILayout.EndScrollView(); //DrawList("Objects", list.ToArray(), ""); }
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(); }
public override void OnInspectorGUI() { if (ListTextAssetTexture != null) { GUILayout.Label("Texture: "); ScrollView.vector2Value = GUILayout.BeginScrollView(ScrollView.vector2Value, true, false, GUILayout.Height(600)); for (int i = 0; i < ListTextAssetTexture.arraySize; i++) { GUILayout.BeginHorizontal(); if (CurrentIndexTexProcess.intValue == i) { GUI.color = Color.red; } if (ListTextAsset.GetArrayElementAtIndex(i) == null) { GUILayout.Label("ID " + (i + 1) + ": Missing Object"); } else { GUILayout.Label("ID " + (i + 1) + ": " + ListTextAssetTexture.GetArrayElementAtIndex(i).stringValue); } GUILayout.FlexibleSpace(); if (GUILayout.Button("Get", GUILayout.Width(40))) { PathTex.stringValue = EditorUtility.OpenFilePanel("Load texture", PathTex.stringValue.Replace(Application.dataPath, "Assets/"), ""); CurrentIndexTexProcess.intValue = i; if (PathTex.stringValue != null) { IsGetFileTex.boolValue = true; } } if (GUILayout.Button("Del")) { IsDeleteTex.boolValue = true; CurrentIndexTexProcess.intValue = i; } if (IsSprite.arraySize > i && IsSprite.GetArrayElementAtIndex(i) != null) { IsSprite.GetArrayElementAtIndex(i).boolValue = GUILayout.Toggle(IsSprite.GetArrayElementAtIndex(i).boolValue, "Sprite"); } if (GUILayout.Button("...")) { EditorGUIUtility.PingObject(ListTextAsset.GetArrayElementAtIndex(i).objectReferenceValue); } GUI.color = Color.white; GUILayout.Space(20); GUILayout.EndHorizontal(); } GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("New", GUILayout.Width(150))) { ScrollView.vector2Value += new Vector2(0, 50); IsCreateNewTexture.boolValue = true; } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.EndScrollView(); GUILayout.Label("***********************************************************************************************************************", GUILayout.MinWidth(0)); } bool oldIsCustomFolder = IsCustomFolder.boolValue; IsCustomFolder.boolValue = GUILayout.Toggle(IsCustomFolder.boolValue, "Is Save Custom Folder"); if (IsCustomFolder.boolValue) { if (!oldIsCustomFolder) { oldIsCustomFolder = true; PathCustom.stringValue = EditorUtility.OpenFolderPanel("Save file at", PathCustom.stringValue.Replace(Application.dataPath, "Assets/"), ""); } GUILayout.Label("Current save folder: " + PathCustom.stringValue.Replace(Application.dataPath, "Assets/")); } serializedObject.ApplyModifiedProperties(); base.OnInspectorGUI(); }
// Render the log output in a scroll view. void GUIDisplayLog() { scrollViewVector = GUILayout.BeginScrollView(scrollViewVector); GUILayout.Label(logText); GUILayout.EndScrollView(); }
void OnGUI() { EditMode = GUILayout.Toggle(EditMode, "Edit"); if (GUI.changed) { if (EditMode) { GetSelection(); } else { ResetPreview(); } } KeepOriginalNames = GUILayout.Toggle(KeepOriginalNames, "Keep names"); ApplyRotation = GUILayout.Toggle(ApplyRotation, "Apply rotation"); ApplyScale = GUILayout.Toggle(ApplyScale, "Apply scale"); GUILayout.Space(5); if (EditMode) { ResetPreview(); GUI.color = Color.yellow; if (Prefab != null) { GUILayout.Label("Prefab: "); GUILayout.Label(Prefab.name); } else { GUILayout.Label("No prefab selected"); } GUI.color = Color.white; GUILayout.Space(5); GUILayout.BeginScrollView(new Vector2()); foreach (GameObject go in ObjectsToReplace) { GUILayout.Label(go.name); if (Prefab != null && go.name.Contains(Prefab.name)) { GameObject newObject; newObject = (GameObject)PrefabUtility.InstantiatePrefab(Prefab); newObject.transform.SetParent(go.transform.parent, true); newObject.transform.localPosition = go.transform.localPosition; if (ApplyRotation) { newObject.transform.localRotation = go.transform.localRotation; } if (ApplyScale) { newObject.transform.localScale = go.transform.localScale; } TempObjects.Add(newObject); if (KeepOriginalNames) { newObject.transform.name = go.transform.name; } go.SetActive(false); } } GUILayout.EndScrollView(); GUILayout.Space(5); GUILayout.BeginHorizontal(); if (GUILayout.Button("Apply")) { foreach (GameObject go in ObjectsToReplace) { if (go.name.Contains(Prefab.name)) { DestroyImmediate(go); } } EditMode = false; EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); // So that we don't forget to save... } ; if (GUILayout.Button("Cancel")) { ResetPreview(); EditMode = false; } ; GUILayout.EndHorizontal(); } else { ObjectsToReplace = new GameObject[0]; TempObjects.Clear(); Prefab = null; } }
private void displayWindow(int id) { if (GUI.Button(new Rect(window.width - 16, 2, 14, 14), "")) { AppLauncherFlight.bDisplayAssistant = false; } if (IsPaused()) { GUILayout.Box("CONTROL PAUSED", GeneralUI.labelAlertStyle); } GUI.backgroundColor = GeneralUI.HeaderButtonBackground; if (GUILayout.Button("Options", GUILayout.Width(205))) { bShowSettings = !bShowSettings; } GUI.backgroundColor = GeneralUI.stockBackgroundGUIColor; if (bShowSettings) { showPresets = GUILayout.Toggle(showPresets, showPresets ? "Hide Presets" : "Show Presets", GUILayout.Width(200)); showPIDLimits = GUILayout.Toggle(showPIDLimits, showPIDLimits ? "Hide PID Limits" : "Show PID Limits", GUILayout.Width(200)); showControlSurfaces = GUILayout.Toggle(showControlSurfaces, showControlSurfaces ? "Hide Control Surfaces" : "Show Control Surfaces", GUILayout.Width(200)); } #region Hdg GUI GUILayout.BeginHorizontal(); // button background colour GUI.backgroundColor = GeneralUI.HeaderButtonBackground; if (GUILayout.Button("Roll and Yaw Control", GUILayout.Width(186))) { bShowHdg = !bShowHdg; } // Toggle colour if (bHdgActive) { GUI.backgroundColor = GeneralUI.ActiveBackground; } else { GUI.backgroundColor = GeneralUI.InActiveBackground; } bool toggleCheck = GUILayout.Toggle(bHdgActive, ""); if (toggleCheck != bHdgActive) { bHdgActive = toggleCheck; bPause = false; SurfSAS.setStockSAS(false); SurfSAS.ActivitySwitch(false); } // reset colour GUI.backgroundColor = GeneralUI.stockBackgroundGUIColor; GUILayout.EndHorizontal(); if (bShowHdg) { bWingLeveller = GUILayout.Toggle(bWingLeveller, bWingLeveller ? "Mode: Wing Leveller" : "Mode: Hdg Control", GUILayout.Width(200)); if (!bWingLeveller) { GUILayout.BeginHorizontal(); if (GUILayout.Button("Target Hdg: ", GUILayout.Width(98))) { double newHdg; if (double.TryParse(targetHeading, out newHdg) && newHdg >= 0 && newHdg <= 360) { Utils.GetAsst(PIDList.HdgBank).SetPoint = newHdg; Utils.GetAsst(PIDList.HdgYaw).SetPoint = newHdg; bHdgActive = bHdgWasActive = true; // skip toggle check to avoid being overwritten } } targetHeading = GUILayout.TextField(targetHeading, GUILayout.Width(98)); GUILayout.EndHorizontal(); } scrollbarHdg = GUILayout.BeginScrollView(scrollbarHdg, GUILayout.Height(hdgScrollHeight)); if (!bWingLeveller) { drawPIDvalues(PIDList.HdgBank, "Heading", "\u00B0", FlightData.heading, 2, "Bank", "\u00B0", false, true, false); drawPIDvalues(PIDList.HdgYaw, "Bank => Yaw", "\u00B0", FlightData.yaw, 2, "Yaw", "\u00B0", true, false, false); } if (showControlSurfaces) { drawPIDvalues(PIDList.Aileron, "Bank", "\u00B0", FlightData.roll, 3, "Deflection", "\u00B0", false, true, false); drawPIDvalues(PIDList.Rudder, "Yaw", "\u00B0", FlightData.yaw, 3, "Deflection", "\u00B0", false, true, false); } GUILayout.EndScrollView(); Utils.GetAsst(PIDList.Aileron).OutMin = Math.Min(Math.Max(Utils.GetAsst(PIDList.Aileron).OutMin, -1), 1); Utils.GetAsst(PIDList.Aileron).OutMax = Math.Min(Math.Max(Utils.GetAsst(PIDList.Aileron).OutMax, -1), 1); Utils.GetAsst(PIDList.Rudder).OutMin = Math.Min(Math.Max(Utils.GetAsst(PIDList.Rudder).OutMin, -1), 1); Utils.GetAsst(PIDList.Rudder).OutMax = Math.Min(Math.Max(Utils.GetAsst(PIDList.Rudder).OutMax, -1), 1); } #endregion #region Pitch GUI GUILayout.BeginHorizontal(); // button background GUI.backgroundColor = GeneralUI.HeaderButtonBackground; if (GUILayout.Button("Vertical Control", GUILayout.Width(186))) { bShowVert = !bShowVert; } // Toggle colour if (bVertActive) { GUI.backgroundColor = GeneralUI.ActiveBackground; } else { GUI.backgroundColor = GeneralUI.InActiveBackground; } toggleCheck = GUILayout.Toggle(bVertActive, ""); if (toggleCheck != bVertActive) { bVertActive = toggleCheck; if (!toggleCheck) { bPause = false; } SurfSAS.setStockSAS(false); SurfSAS.ActivitySwitch(false); } // reset colour GUI.backgroundColor = GeneralUI.stockBackgroundGUIColor; GUILayout.EndHorizontal(); if (bShowVert) { bAltitudeHold = GUILayout.Toggle(bAltitudeHold, bAltitudeHold ? "Mode: Altitude" : "Mode: Vertical Speed", GUILayout.Width(200)); GUILayout.BeginHorizontal(); if (GUILayout.Button(bAltitudeHold ? "Target Altitude:" : "Target Speed:", GUILayout.Width(98))) { ScreenMessages.PostScreenMessage("Target " + (PilotAssistant.Instance.bAltitudeHold ? "Altitude" : "Vertical Speed") + " updated"); double newVal; double.TryParse(targetVert, out newVal); if (bAltitudeHold) { Utils.GetAsst(PIDList.Altitude).SetPoint = newVal; } else { Utils.GetAsst(PIDList.VertSpeed).SetPoint = newVal; } bVertActive = bVertWasActive = true; // skip the toggle check so value isn't overwritten } targetVert = GUILayout.TextField(targetVert, GUILayout.Width(98)); GUILayout.EndHorizontal(); scrollbarVert = GUILayout.BeginScrollView(scrollbarVert, GUILayout.Height(vertScrollHeight)); if (bAltitudeHold) { drawPIDvalues(PIDList.Altitude, "Altitude", "m", FlightData.thisVessel.altitude, 2, "Speed ", "m/s", true, true, false); } drawPIDvalues(PIDList.VertSpeed, "Vertical Speed", "m/s", FlightData.thisVessel.verticalSpeed, 2, "AoA", "\u00B0", true); if (showControlSurfaces) { drawPIDvalues(PIDList.Elevator, "Angle of Attack", "\u00B0", FlightData.AoA, 3, "Deflection", "\u00B0", true, true, false); } Utils.GetAsst(PIDList.Elevator).OutMin = Math.Min(Math.Max(Utils.GetAsst(PIDList.Elevator).OutMin, -1), 1); Utils.GetAsst(PIDList.Elevator).OutMax = Math.Min(Math.Max(Utils.GetAsst(PIDList.Elevator).OutMax, -1), 1); GUILayout.EndScrollView(); } #endregion #region Throttle GUI GUILayout.BeginHorizontal(); // button background GUI.backgroundColor = GeneralUI.HeaderButtonBackground; if (GUILayout.Button("Throttle Control", GUILayout.Width(186))) { bShowThrottle = !bShowThrottle; } // Toggle colour if (bThrottleActive) { GUI.backgroundColor = GeneralUI.ActiveBackground; } else { GUI.backgroundColor = GeneralUI.InActiveBackground; } toggleCheck = GUILayout.Toggle(bThrottleActive, ""); if (toggleCheck != bThrottleActive) { bThrottleActive = toggleCheck; if (!toggleCheck) { bPause = false; } SurfSAS.setStockSAS(false); SurfSAS.ActivitySwitch(false); } // reset colour GUI.backgroundColor = GeneralUI.stockBackgroundGUIColor; GUILayout.EndHorizontal(); if (bShowThrottle) { GUILayout.BeginHorizontal(); if (GUILayout.Button("Target Velocity:", GUILayout.Width(118))) { ScreenMessages.PostScreenMessage("Target Velocity updated"); double newVal; double.TryParse(targetSpeed, out newVal); Utils.GetAsst(PIDList.Throttle).SetPoint = newVal; bThrottleActive = bWasThrottleActive = true; // skip the toggle check so value isn't overwritten } targetSpeed = GUILayout.TextField(targetSpeed, GUILayout.Width(78)); GUILayout.EndHorizontal(); drawPIDvalues(PIDList.Throttle, "Velocity", "m/s", FlightData.thisVessel.srfSpeed, 2, "Throttle", "", true); // can't have people bugging things out now can we... Utils.GetAsst(PIDList.Throttle).OutMin = Math.Min(Math.Max(Utils.GetAsst(PIDList.Throttle).OutMin, -1), 0); Utils.GetAsst(PIDList.Throttle).OutMax = Math.Min(Math.Max(Utils.GetAsst(PIDList.Throttle).OutMax, -1), 0); } #endregion GUI.DragWindow(); }
private void OnGUI() { if (magiCloud == null) { magiCloud = Resources.Load <GUISkin>("MagiCloud"); } if (labelStyle == null) { labelStyle = new GUIStyle(magiCloud.label); labelStyle.fontSize = 13; } OnInitTags(); OnInitLayers(); scrollPos = GUILayout.BeginScrollView(scrollPos, GUILayout.Width(position.width), GUILayout.Height(position.height)); GUILayout.BeginVertical(); GUILayout.Space(10); GUILayout.Label("创建/查找框架预制物体", magiCloud.label); GUILayout.BeginHorizontal(); initialize = (MInitialize)EditorGUILayout.ObjectField(new GUIContent("场景框架预知物体:", "查询场景框架预制物体,如果场景不存在,可点击创建可自动创建,也可通过创建按钮,自动查找"), initialize, typeof(MInitialize), false, GUILayout.Width(400), GUILayout.Height(20)); GUILayout.Space(10); if (GUILayout.Button(new GUIContent("创建/查找", "如果场景框架预制物体为Null,自动会在场景中创建,如果场景框架预制物体不为Null,但是编辑器窗口为Null,则点击该按钮自动赋值"), GUILayout.Width(120), GUILayout.Height(20))) { initialize = FindObjectOfType <MInitialize>(); if (initialize == null) { GameObject featuresObject = Resources.Load <GameObject>("MagiCloud"); var newFeatures = Instantiate <GameObject>(featuresObject); newFeatures.name = featuresObject.name; initialize = newFeatures.GetComponent <MInitialize>(); } Selection.activeGameObject = initialize.gameObject; } GUILayout.EndHorizontal(); if (FrameConfig.Config != null) { #region 高亮公用参数配置 GUILayout.Space(20); GUILayout.Label("高亮公用参数配置", magiCloud.label); //FrameConfig.Config.highlightType = (HighlightType)EditorGUILayout.EnumPopup(new GUIContent("高亮类型:","可通过代码FrameConfig.highlightType返回以及设置相关参数"),FrameConfig.Config.highlightType // ,GUILayout.Width(250),GUILayout.Height(20)); GUILayout.Space(5); FrameConfig.Config.highlightColor = EditorGUILayout.ColorField(new GUIContent("高亮颜色:", "可通过代码FrameConfig.highlightColor获取高亮颜色"), FrameConfig.Config.highlightColor , GUILayout.Width(350), GUILayout.Height(20)); FrameConfig.Config.grabColor = EditorGUILayout.ColorField(new GUIContent("高亮颜色:", "可通过代码FrameConfig.grabColor获取高亮颜色"), FrameConfig.Config.grabColor , GUILayout.Width(350), GUILayout.Height(20)); //switch (FrameConfig.Config.highlightType) //{ // case HighlightType.Shader: // FrameConfig.Config.highlightColor = EditorGUILayout.ColorField(new GUIContent("高亮颜色:","可通过代码FrameConfig.highlightColor获取高亮颜色"),FrameConfig.Config.highlightColor // ,GUILayout.Width(350),GUILayout.Height(20)); // FrameConfig.Config.grabColor = EditorGUILayout.ColorField(new GUIContent("高亮颜色:","可通过代码FrameConfig.grabColor获取高亮颜色"),FrameConfig.Config.grabColor // ,GUILayout.Width(350),GUILayout.Height(20)); // break; // case HighlightType.Model: // break; //} GUILayout.Space(20); #endregion #region 标签公用参数配置 GUILayout.Space(20); GUILayout.Label("标签公用参数配置", magiCloud.label); FrameConfig.Config.labelFont = (Font)EditorGUILayout.ObjectField(new GUIContent("标签字体:"), FrameConfig.Config.labelFont, typeof(Font), true, GUILayout.Width(350), GUILayout.Height(20)); GUILayout.Space(5); //标签颜色 EditorGUI.BeginChangeCheck(); FrameConfig.Config.labelColor = EditorGUILayout.ColorField(new GUIContent("标签颜色:", "可通过代码FrameConfig.labelColor获取高亮颜色"), FrameConfig.Config.labelColor , GUILayout.Width(350), GUILayout.Height(20)); if (EditorGUI.EndChangeCheck()) { KGUI.KGUI_LabelController.Instance.SetAllFontColor(FrameConfig.Config.labelColor); } //标签字体大小 EditorGUI.BeginChangeCheck(); FrameConfig.Config.labelFontSize = EditorGUILayout.IntField(new GUIContent("标签字体大小:", "可通过代码FrameConfig.labelFontSize获取字体大小"), FrameConfig.Config.labelFontSize, GUILayout.Width(350), GUILayout.Height(20)); if (EditorGUI.EndChangeCheck()) { KGUI.KGUI_LabelController.Instance.SetAllFontSize(FrameConfig.Config.labelFontSize); } GUILayout.Space(5); //标签背景图片 EditorGUI.BeginChangeCheck(); FrameConfig.Config.labelBg = (Sprite)EditorGUILayout.ObjectField(new GUIContent("标签背景图片:", "可通过代码FrameConfig.labelBg获取背景图片"), FrameConfig.Config.labelBg, typeof(Sprite), true, GUILayout.Width(350), GUILayout.Height(60)); if (EditorGUI.EndChangeCheck()) { KGUI.KGUI_LabelController.Instance.SetAllLabelBG(FrameConfig.Config.labelBg); } #endregion } #region 生成框架所需Tags以及Layer层 GUILayout.Label("生成框架所需Tags以及Layer层", magiCloud.label); GUILayout.BeginHorizontal(); GUILayout.Space(10); GUILayout.BeginVertical("box"); GUILayout.Label("框架Tag信息", labelStyle); foreach (var item in tagInfos) { GUILayout.Label(item.TagID + ": " + item.Use); } //if (GUILayout.Button(new GUIContent("生成框架Tag", "如果此时Editor Tags不足框架所需Tag,点击此按钮自动生成"), GUILayout.Width(100), GUILayout.Height(20))) //{ // foreach (var item in tagInfos) // { // AddTag(item.TagID); // } //} GUILayout.Space(20); GUILayout.Label("框架Layer信息", labelStyle); foreach (var item in layerInfos) { GUILayout.Label(item.LayerID + ": " + item.Use); } //if (GUILayout.Button(new GUIContent("生成框架Layer", "如果此时Editor Layer不足框架所需Layer,点击此按钮自动生成"), GUILayout.Width(100), GUILayout.Height(20))) //{ // foreach (var item in layerInfos) // { // AddLayer(item.LayerID); // } //} GUILayout.EndVertical(); GUILayout.EndHorizontal(); #endregion GUILayout.EndVertical(); GUILayout.Space(20); GUILayout.EndScrollView(); }
/// <summary> /// A window displaying the logged messages. /// </summary> static void ConsoleWindow(int windowID) { if (scrollToBottom) { GUILayout.BeginScrollView(Vector2.up * entries.Count * 100.0f); } else { scrollPos = GUILayout.BeginScrollView(scrollPos); } // Go through each logged entry for (int i = 0; i < entries.Count; i++) { ConsoleMessage entry = entries[i]; // If this message is the same as the last one and the collapse feature is chosen, skip it if (collapse && i > 0 && entry.message == entries[i - 1].message) { continue; } // Change the text colour according to the log type switch (entry.type) { case LogType.Error: case LogType.Exception: GUI.contentColor = Color.red; break; case LogType.Warning: GUI.contentColor = Color.yellow; break; default: GUI.contentColor = Color.white; break; } if (entry.type == LogType.Exception) { GUILayout.Label(entry.message + " || " + entry.stackTrace); } else { GUILayout.Label(entry.message); } } GUI.contentColor = Color.white; GUILayout.EndScrollView(); // Clear button if (GUILayout.Button("Clear")) { entries.Clear(); } if (GUILayout.Button("Collapse:" + collapse)) { collapse = !collapse; } if (GUILayout.Button("Bottom:" + scrollToBottom)) { scrollToBottom = !scrollToBottom; } // Set the window to be draggable by the top title bar //GUI.DragWindow(new Rect(0, 0, 10000, 20)); }
void PrefabPaneli() { //Yaratacağımız arayüz için stillendirme oluşturuyoruz GUIStyle areaStyle = new GUIStyle(GUI.skin.box); areaStyle.alignment = TextAnchor.UpperCenter; //Oluşturacağımız panelin ölçülerini ve konum bilgisini tutmak için bir Rect değişkeni oluşturduk. Rect panelRect; //Eğer mouse konumunda açmak istiyorsak, daha öncesinde oluşturduğumuz sahnePaneliPos isimli değişkeni kullanıyoruz. if (mousePanelAc) { panelRect = new Rect(sahnePaneliPos.x, sahnePaneliPos.y, 200, 300); } else { /* * Mouse konumunda açılmasını istemediğimiz zamanlarda sol tarafta olmasını istiyorum. * Bu yüzden Rect değişkeninin ilk 2 değişkeni sıfır, yani sol üstten başlatıyoruz. * 240 birim genişlik, sabit olmasını istediğim için. * Son değişken ise Scene panelinin yüksekliğini elde etmemizi sağlayan bir kod. Yani * Scene panelinin yüksekliği ile bizim oluşturduğumuz panelin yüksekliği aynı ölçüde olacak. */ panelRect = new Rect(0, 0, 240, SceneView.currentDrawingSceneView.camera.scaledPixelHeight); } /* * BeginArea ve EndArea bir arayüz bölgesi oluşturmak için kullandığımız komut. * Bu ikisi arasında yazdığımız arayüz bileşenleri BeginArea içinde verdiğimiz * ilk değişken olan Rect tipi değişkene göre belirli bir alan içerisinde kalacak. * 2. değişken olarak ise stil değişkeni veriyoruz. */ GUILayout.BeginArea(panelRect, areaStyle); /* * Klasörleri seçilebilir halde tutmak istiyorum ve bunları bir scrollview içerisinde tutarak * kaydırılabilir bir panel içerisinde tutacağım. * BeginScrollView ile aşağı-yukarı, sağa-sola kaydırılabilir bölümler oluşturabilirim. * Sırasıyla değişkenleri yazarsak * 1.klasorPanelScroll:Kaydırmanın hangi durumda olduğunu gösteriyor, sağ mı sol mu aşağı mı yukarı mı, bunun verisini vector2 olarak tutuyoruz. * Dikkat ederseniz = ile yine klasorPanelScroll değişkenine atama yapıyoruz. Scrollview üzerinde kaydırma yaptığımızda, bu şekilde verimizi güncelleyebiliyoruz, sabit kalmıyor. * 2. değişken true değere sahip, bu değişkenin karşılığı horizontalScroll aslında, yani sağa sola kaydırma. Ben de bu şekilde olmasını istediğim için true veriyorum. * 3. değişken de bu sefer dikeyde kaydırma durumunu soruyor, false veriyorum. Çünkü yatayda kaydırma olmasını istemiyorum. * 4. değişkende horizontal yani yatay kaydırma çubuğum için istediğim stili veriyorum * 5. değişken de vertical yani dikey kaydırma çubuğu için stil değişkeni, herhangi bir stil atamasını istemiyorum. * 6. değişken de ölçülerde sınırlandırma yapmamızı sağlayan değişken. MinHeight 40 vererek, en az 40 birim yükseklikte olmasını sağlıyorum. */ klasorPanelScroll = GUILayout.BeginScrollView(klasorPanelScroll, true, false, GUI.skin.horizontalScrollbar, GUIStyle.none, GUILayout.MinHeight(40)); /* * ScrollView içerisine bir adet toolbar koyuyorum. Bu aslında bir sürü butonu içinde barındıran ancak sadece 1 tanesinin aktif-seçili olabildiği bir arayüz yapısı. * Bunu da hangi alt klasörün seçildiğini tutmak için kullanıyorum. * Aldığı ilk değişken int tipinde ID değişkeni * 2.değişken ise içerisine dolduracağımız butonlara yazılacak isimlerin olduğu altKlasörler dizisi. * Yine dikkat ederseniz, oluşturduğumuz arayüzden veriyi alabilmek için = ile seciliKlasor değişkenine atama yapıyorum. */ seciliKlasor = GUILayout.Toolbar(seciliKlasor, altKlasorler); //EndScrollView komutunu çağırmayı unutmayın. GUILayout.EndScrollView(); /* * Bu sefer de prefabları göstereceğim bir scrollview oluşturacağım. * Bir önceki ScrollView dan farklı olarak bu sefer dikeyde yani vertical halde hareket istiyorum. * Yine MinHeight kullandım ancak dikkat ederseniz, Area için verdiğim panelRect yüksekliğinden 40 çıkarıyorum. * Bu sayede bu iki ScrollView birbirine tam olarak oturup ekranı kaplayacaklar. * Ayrıca bu sefer prefabPanelScroll değişkenini kullandığım dikkatinizden kaçmasın. Her bir scroll için ayrı bir değişkende bu veriyi tutmamız gerekiyor. */ prefabPanelScroll = GUILayout.BeginScrollView(prefabPanelScroll, false, true, GUIStyle.none, GUI.skin.verticalScrollbar, GUILayout.MinHeight(panelRect.height - 40)); /* * Toolbar sayesinde elde ettiğim seçiliKlasor ile sadece istediğimiz klasördeki prefabları * sırayla dolanıp ekranda bunlar için birer arayüz elemanı oluşturuyorum. */ for (int i = 0; i < klasorPrefablari[seciliKlasor].Count; i++) { /* * Bu kısımda yaptığım şey prefab ismini elde edebilmek için * bir filtreleme işlemi. Dosya yolu halinde tuttuğum için * elimize geçen veri "klasorismi/isim.prefab" formatında. * Burada da sadece isim kısmına erişmek için filtreleme yapıyorum. * Substring ile en sondaki slash "/" sonrası ve .prefab öncesi kısımları alarak * isim değerini elde ediyorum. */ int index = klasorPrefablari[seciliKlasor][i].LastIndexOf("/"); string isim = ""; if (index >= 0) { isim = klasorPrefablari[seciliKlasor][i].Substring(index + 1, klasorPrefablari[seciliKlasor][i].Length - index - 8); } else { isim = klasorPrefablari[seciliKlasor][i]; } /* * Özelleştirilebilir halde bir buton oluşturmak için * GUIContent tipinde bir değişken oluşturuyorum. * text değişkenine ismi, image değişkenine ise prefabGorseliAl * fonksiyonu ile elde ettiğim resim verisini atıyorum. */ GUIContent icerik = new GUIContent(); icerik.text = isim; icerik.image = prefabGorseliAl(klasorPrefablari[seciliKlasor][i]); /* * Her bir prefab için ayrı ayrı butonları oluşturuyorum. Dikkat ederseniz Button'da değişken olarak icerik değişkenini kullandım. * Ve bu butonların tıklanma durumuna da ObjeOlustur isimli fonksiyonu veriyorum. */ if (GUILayout.Button(icerik)) { ObjeOlustur(klasorPrefablari[seciliKlasor][i]); } } //Prefablar için olan scrollview elemanını sonlandırıyorum. GUILayout.EndScrollView(); //Arayüz panelimi sonlandırıyorum. GUILayout.EndArea(); }
private void VersionGUI() { GUILayout.BeginHorizontal(); GUILayout.Label("Version: ", GUILayout.Width(60)); GUI.enabled = _versionInfo.PreviousVersions.Count > 0; if (GUILayout.Button(_versionNumber, EditorGlobalTools.Styles.MiniPopup)) { GenericMenu gm = new GenericMenu(); for (int i = 0; i < _versionInfo.PreviousVersions.Count; i++) { Version version = _versionInfo.PreviousVersions[i]; if (version == _version) { gm.AddDisabledItem(new GUIContent(version.GetFullNumber()), true); } else { gm.AddItem(new GUIContent(version.GetFullNumber()), false, () => { _version = version; _versionNumber = _version.GetFullNumber(); }); } } gm.ShowAsContext(); GUI.FocusControl(null); } if (IsAdminMode) { GUI.backgroundColor = AdminModeColor; if (GUILayout.Button("Delete", EditorStyles.miniButton, GUILayout.Width(50))) { if (EditorUtility.DisplayDialog("Prompt", "Are you sure you want to delete this version?", "Yes", "No")) { if (_version != null) { _versionInfo.PreviousVersions.Remove(_version); _version = _versionInfo.PreviousVersions.Count > 0 ? _versionInfo.PreviousVersions[0] : null; _versionNumber = _version != null?_version.GetFullNumber() : "<None>"; HasChanged(_versionInfo); } } } GUI.backgroundColor = Color.white; } GUI.enabled = true; GUILayout.EndHorizontal(); if (_version != null) { GUILayout.BeginHorizontal(); GUILayout.Label("Release Date: " + _version.ReleaseDate); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Supported Unity Versions: " + _versionInfo.CurrentVersion.UnityVersions); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Scripting Runtime Versions: " + _versionInfo.CurrentVersion.ScriptingVersions); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Api Compatibility Level: " + _versionInfo.CurrentVersion.APIVersions); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Release Notes:"); GUILayout.EndHorizontal(); GUILayout.BeginVertical(); _scroll = GUILayout.BeginScrollView(_scroll); GUILayout.Label(_version.ReleaseNotes); GUILayout.EndScrollView(); GUILayout.EndVertical(); } if (IsAdminMode) { GUI.backgroundColor = AdminModeColor; GUILayout.BeginHorizontal(); GUI.enabled = !_isRelease; if (GUILayout.Button("Version Release")) { _isRelease = true; } GUI.enabled = true; GUILayout.EndHorizontal(); if (_isRelease) { ReleaseGUI(); } GUI.backgroundColor = Color.white; } }
void StandardOptions() { GUILayout.BeginArea(mainOptionsRect); scrollPosition = GUILayout.BeginScrollView(scrollPosition); GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUILayout.Label("Stopping Mode", GUILayout.Width(standardButtonWidth)); if (GUILayout.Button(rae.stopCondition.ToString(), GUILayout.Width(standardButtonWidth))) { rae.stopCondition++; if (rae.stopCondition > ReplayAnalysisEngine.StoppingCondition.Custom) { rae.stopCondition = ReplayAnalysisEngine.StoppingCondition.Instant; } } GUILayout.EndHorizontal(); switch (rae.stopCondition) { case ReplayAnalysisEngine.StoppingCondition.Instant: break; case ReplayAnalysisEngine.StoppingCondition.WaitForStop: case ReplayAnalysisEngine.StoppingCondition.Time: case ReplayAnalysisEngine.StoppingCondition.Custom: GUILayout.BeginHorizontal(); GUILayout.Label("Time Acceleration", GUILayout.Width(standardButtonWidth)); rae.TimeAcceleration = FormatFloat(GUILayout.TextField(rae.TimeAcceleration + "", GUILayout.Width(standardButtonWidth))); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Time Out After", GUILayout.Width(standardButtonWidth)); rae.TimeOut = FormatFloat(GUILayout.TextField(rae.TimeOut + "", GUILayout.Width(standardButtonWidth))); GUILayout.EndHorizontal(); break; } rae.AddActions = GUILayout.Toggle(rae.AddActions, "Add Action Objects", GUILayout.Width(standardButtonWidth * 1.5f)); //rae.TakeScreenShots = GUILayout.Toggle(rae.TakeScreenShots,"Take Screen Shots",GUILayout.Width(standardButtonWidth * 1.5f)); //maybe put some options in here GUILayout.BeginHorizontal(); GUILayout.Label("Iteration Mode", GUILayout.Width(standardButtonWidth)); if (GUILayout.Button(rae.iterationMode.ToString(), GUILayout.Width(standardButtonWidth))) { rae.iterationMode++; if (rae.iterationMode > ReplayAnalysisEngine.IterationMode.ActionByAction) { rae.iterationMode = ReplayAnalysisEngine.IterationMode.FinalStates; } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Pause After", GUILayout.Width(standardButtonWidth)); string temp = GUILayout.TextField(rae.PauseAfter < 0 ? "Don't Pause" : rae.PauseAfter + "", GUILayout.Width(standardButtonWidth)); if (temp != "Don't Pause") { rae.PauseAfter = FormatInt(temp); } GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.EndScrollView(); GUILayout.EndArea(); }
protected override void OnInspectorDefaultGUI() { base.OnInspectorDefaultGUI(); GUILayout.BeginHorizontal(); GUILayout.Label("Step Number: " + Target.Content.Count); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Export Step Data To .txt")) { string path = EditorUtility.SaveFilePanel("保存数据文件", Application.dataPath, Target.name, "txt"); if (path != "") { for (int i = 0; i < Target.Content.Count; i++) { EditorUtility.DisplayProgressBar("Export......", i + "/" + Target.Content.Count, (float)i / Target.Content.Count); if (Target.Content[i].Ancillary != "") { File.AppendAllText(path, "【" + Target.Content[i].Ancillary + "】\r\n"); } File.AppendAllText(path, (i + 1) + "、" + Target.Content[i].Name + "\r\n" + Target.Content[i].Prompt + "\r\n"); } EditorUtility.ClearProgressBar(); } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Export Step Name To .txt")) { string path = EditorUtility.SaveFilePanel("保存数据文件", Application.dataPath, Target.name, "txt"); if (path != "") { for (int i = 0; i < Target.Content.Count; i++) { EditorUtility.DisplayProgressBar("Export......", i + "/" + Target.Content.Count, (float)i / Target.Content.Count); if (Target.Content[i].Ancillary != "") { File.AppendAllText(path, "【" + Target.Content[i].Ancillary + "】\r\n"); } File.AppendAllText(path, Target.Content[i].Name + "\r\n"); } EditorUtility.ClearProgressBar(); } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Export Step Prompt To .txt")) { string path = EditorUtility.SaveFilePanel("保存数据文件", Application.dataPath, Target.name, "txt"); if (path != "") { for (int i = 0; i < Target.Content.Count; i++) { EditorUtility.DisplayProgressBar("Export......", i + "/" + Target.Content.Count, (float)i / Target.Content.Count); File.AppendAllText(path, Target.Content[i].Prompt + "\r\n"); } EditorUtility.ClearProgressBar(); } } GUILayout.EndHorizontal(); _scroll = GUILayout.BeginScrollView(_scroll); for (int i = 0; i < Target.Content.Count; i++) { if (Target.Content[i].Ancillary != "") { GUILayout.BeginHorizontal(); GUILayout.Label("【" + Target.Content[i].Ancillary + "】"); GUILayout.EndHorizontal(); } GUILayout.BeginHorizontal(); GUILayout.Label(i + "." + Target.Content[i].Name); GUILayout.FlexibleSpace(); GUILayout.Label("[" + Target.Content[i].Trigger + "]"); GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); }
public void OnGUI() { if (animationClips.Count > 0) { scrollPos = GUILayout.BeginScrollView(scrollPos, GUIStyle.none); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Animation Clip:", GUILayout.Width(columnWidth)); if (animationClips.Count == 1) { animationClips[0] = ((AnimationClip)EditorGUILayout.ObjectField( animationClips[0], typeof(AnimationClip), true, GUILayout.Width(columnWidth)) ); } else { GUILayout.Label("Multiple Anim Clips: " + animationClips.Count, GUILayout.Width(columnWidth)); } EditorGUILayout.EndHorizontal(); GUILayout.Space(20); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Sprites:"); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Original Sprite Text:", GUILayout.Width(columnWidth)); GUILayout.Label("Replacement Sprite Text:", GUILayout.Width(columnWidth)); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); originalSpriteText = EditorGUILayout.TextField(originalSpriteText, GUILayout.Width(columnWidth)); replaceSpriteText = EditorGUILayout.TextField(replaceSpriteText, GUILayout.Width(columnWidth)); if (GUILayout.Button("Replace All Sprites")) { changeAllSprites = true; } EditorGUILayout.EndHorizontal(); foreach (AnimationClip clip in animationClips) { // First you need to create e Editor Curve Binding EditorCurveBinding curveBinding = new EditorCurveBinding(); // I want to change the sprites of the sprite renderer, so I put the typeof(SpriteRenderer) as the binding type. curveBinding.type = typeof(SpriteRenderer); // Regular path to the gameobject that will be changed (empty string means root) curveBinding.path = ""; // This is the property name to change the sprite of a sprite renderer curveBinding.propertyName = "m_Sprite"; // An array to hold the object keyframes ObjectReferenceKeyframe[] keyFrames = new ObjectReferenceKeyframe[10]; foreach (var binding in AnimationUtility.GetObjectReferenceCurveBindings(clip)) { if (binding.propertyName == "m_Sprite") { ObjectReferenceKeyframe[] keyframes = AnimationUtility.GetObjectReferenceCurve(clip, binding); EditorGUILayout.LabelField(binding.path + "/" + binding.propertyName + ", Keys: " + keyframes.Length); for (int i = 0; i < keyframes.Length; i++) { if (changeAllSprites) { Sprite keyframeSprite = (Sprite)keyframes[i].value; if (keyframeSprite != null) { string spriteName = keyframeSprite.name; string newSpriteName = spriteName.Replace(originalSpriteText, replaceSpriteText); Debug.Log(newSpriteName); GetAllSprites(); if (sprites.Length > 0) { bool foundSprite = false; foreach (Sprite sprite in sprites) { if (sprite != null && sprite.name == newSpriteName) { float timeForKey = keyframes[i].time; keyframes[i] = new ObjectReferenceKeyframe(); // set the time keyframes[i].time = timeForKey; // set reference for the sprite you want keyframes[i].value = sprite; AnimationUtility.SetObjectReferenceCurve(clip, binding, keyframes); Debug.Log("Sprite changed to " + sprite.name); break; } } } } } EditorGUILayout.ObjectField(keyframes[i].value, typeof(Sprite), false); } } } } changeAllSprites = false; GUILayout.Space(40); GUILayout.EndScrollView(); } else { GUILayout.Label("Please select an Animation Clip"); } }
public void OnHUDDraw() { GUILayout.BeginVertical(); GUILayout.Box("Leaderboard Operations"); GUILayout.BeginHorizontal(); GUILayout.Label("Leaderboard Id:"); m_lbId = GUILayout.TextField(m_lbId); if (GUILayout.Button("Fetch")) { RetrieveLeaderboard(m_lbId); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Score:"); m_score = GUILayout.TextField(m_score, GUILayout.MinWidth(100)); if (GUILayout.Button("Post")) { long scoreAsLong; if (long.TryParse(m_score, out scoreAsLong)) { PostScore(m_lbId, scoreAsLong); } else { Debug.LogError("Can't parse score to long value"); } } GUILayout.EndHorizontal(); GUILayout.Box("Results"); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); m_showPlayerIds = GUILayout.Toggle(m_showPlayerIds, "Show Player Ids"); GUILayout.EndHorizontal(); m_scrollPosition = GUILayout.BeginScrollView(m_scrollPosition, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); foreach (LBEntry entry in m_lb) { string player; if (m_showPlayerIds) { player = entry.playerId; } else { player = entry.name == "" ? "(no name)" : entry.name; } GUILayout.BeginHorizontal(); GUILayout.Label(entry.rank.ToString() + ":"); GUILayout.Label(player); GUILayout.FlexibleSpace(); GUILayout.Label(entry.score.ToString()); GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); GUILayout.EndVertical(); }
private static void DrawTitleSettingsSubPanel() { float labelWidth = 100; if (PlayFabEditorDataService.AccountDetails.studios != null && PlayFabEditorDataService.AccountDetails.studios.Count != StudioFoldOutStates.Count + 1) { StudioFoldOutStates.Clear(); foreach (var studio in PlayFabEditorDataService.AccountDetails.studios) { if (string.IsNullOrEmpty(studio.Id)) { continue; } if (!StudioFoldOutStates.ContainsKey(studio.Id)) { StudioFoldOutStates.Add(studio.Id, new StudioDisplaySet { Studio = studio }); } foreach (var title in studio.Titles) { if (!StudioFoldOutStates[studio.Id].titleFoldOutStates.ContainsKey(title.Id)) { StudioFoldOutStates[studio.Id].titleFoldOutStates.Add(title.Id, new TitleDisplaySet { Title = title }); } } } } _titleScrollPos = GUILayout.BeginScrollView(_titleScrollPos, PlayFabEditorHelper.uiStyle.GetStyle("gpStyleGray1")); using (new UnityHorizontal(PlayFabEditorHelper.uiStyle.GetStyle("gpStyleClear"))) { EditorGUILayout.LabelField("STUDIOS:", PlayFabEditorHelper.uiStyle.GetStyle("labelStyle"), GUILayout.Width(labelWidth)); GUILayout.FlexibleSpace(); if (GUILayout.Button("REFRESH", PlayFabEditorHelper.uiStyle.GetStyle("Button"))) { PlayFabEditorDataService.RefreshStudiosList(); } } foreach (var studio in StudioFoldOutStates) { var style = new GUIStyle(EditorStyles.foldout); if (studio.Value.isCollapsed) { style.fontStyle = FontStyle.Normal; } studio.Value.isCollapsed = EditorGUI.Foldout(EditorGUILayout.GetControlRect(), studio.Value.isCollapsed, string.Format("{0} ({1})", studio.Value.Studio.Name, studio.Value.Studio.Titles.Length), true, PlayFabEditorHelper.uiStyle.GetStyle("foldOut_std")); if (studio.Value.isCollapsed) { continue; } EditorGUI.indentLevel = 2; using (new UnityHorizontal(PlayFabEditorHelper.uiStyle.GetStyle("gpStyleClear"))) { EditorGUILayout.LabelField("TITLES:", PlayFabEditorHelper.uiStyle.GetStyle("labelStyle"), GUILayout.Width(labelWidth)); } GUILayout.Space(5); // draw title foldouts foreach (var title in studio.Value.titleFoldOutStates) { title.Value.isCollapsed = EditorGUI.Foldout(EditorGUILayout.GetControlRect(), title.Value.isCollapsed, string.Format("{0} [{1}]", title.Value.Title.Name, title.Value.Title.Id), true, PlayFabEditorHelper.uiStyle.GetStyle("foldOut_std")); if (title.Value.isCollapsed) { continue; } EditorGUI.indentLevel = 3; using (new UnityHorizontal(PlayFabEditorHelper.uiStyle.GetStyle("gpStyleClear"))) { EditorGUILayout.LabelField("SECRET KEY:", PlayFabEditorHelper.uiStyle.GetStyle("labelStyle"), GUILayout.Width(labelWidth)); EditorGUILayout.TextField("" + title.Value.Title.SecretKey); } using (new UnityHorizontal(PlayFabEditorHelper.uiStyle.GetStyle("gpStyleClear"))) { EditorGUILayout.LabelField("URL:", PlayFabEditorHelper.uiStyle.GetStyle("labelStyle"), GUILayout.Width(labelWidth)); GUILayout.FlexibleSpace(); if (GUILayout.Button("VIEW IN GAME MANAGER", PlayFabEditorHelper.uiStyle.GetStyle("textButton"))) { Application.OpenURL(title.Value.Title.GameManagerUrl); } GUILayout.FlexibleSpace(); } EditorGUI.indentLevel = 2; } EditorGUI.indentLevel = 0; } GUILayout.EndScrollView(); }
protected void WindowGUI(int windowID) { GUILayout.BeginVertical(GUILayout.Width(GUI_WIDTH)); // Output grouping selectors GUILayout.BeginHorizontal(); GUILayout.Label("Group by: ", GUILayout.ExpandWidth(false)); if (ContractSystem.Instance != null) { if (GUILayout.Toggle(Config.displayMode == Config.DisplayMode.CONTRACT, "Contract")) { Config.displayMode = Config.DisplayMode.CONTRACT; } } else { Config.displayMode = Config.DisplayMode.CELESTIAL_BODY; } if (GUILayout.Toggle(Config.displayMode == Config.DisplayMode.CELESTIAL_BODY, "Celestial Body")) { Config.displayMode = Config.DisplayMode.CELESTIAL_BODY; } GUILayout.FlexibleSpace(); if (GUILayout.Button(new GUIContent(Config.addWaypointIcon, "Create Custom Waypoint"), GUI.skin.label)) { CustomWaypointGUI.AddWaypoint(); } GUILayout.Space(4); if (GUILayout.Button(new GUIContent(Config.settingsIcon, "Settings"), GUI.skin.label)) { showSettings = !showSettings; if (!showSettings) { Config.Save(); } } GUILayout.EndHorizontal(); scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.ExpandWidth(true), GUILayout.Height(520)); if (Config.displayMode == Config.DisplayMode.CONTRACT) { foreach (WaypointData.ContractContainer cc in WaypointData.ContractContainers) { Contract c = cc.contract; string title = (c != null ? c.Title : "No contract"); if (GUILayout.Button(title, headerButtonStyle, GUILayout.MaxWidth(GUI_WIDTH - 24.0f))) { cc.hidden = !cc.hidden; } if (!cc.hidden) { foreach (WaypointData wpd in cc.waypointByContract.OrderBy(wp => wp.waypoint.name + wp.waypoint.index)) { WaypointLineGUI(wpd); } } } } else { foreach (KeyValuePair <CelestialBody, List <WaypointData> > pair in WaypointData.WaypointByBody) { CelestialBody b = pair.Key; bool hidden = hiddenBodies.ContainsKey(b) && hiddenBodies[b]; if (GUILayout.Button(b.name, headerButtonStyle, GUILayout.MaxWidth(GUI_WIDTH - 24.0f))) { hidden = !hidden; hiddenBodies[b] = hidden; } if (!hidden) { foreach (WaypointData wpd in pair.Value.OrderBy(wp => wp.waypoint.name + wp.waypoint.index)) { WaypointLineGUI(wpd); } } } } GUILayout.EndScrollView(); GUILayout.EndVertical(); GUI.DragWindow(); SetToolTip(0); }
// Draw the GUI. protected virtual void OnGUI() { GUILayout.BeginVertical(); GUILayout.Label(summaryText, EditorStyles.boldLabel); scrollPosition = GUILayout.BeginScrollView(scrollPosition); // Unity text elements can only display up to a small X number of characters (rumors // are ~65k) so generate a set of labels one for each subset of the text being // displayed. int bodyTextOffset = 0; System.Collections.Generic.List <string> bodyTextList = new System.Collections.Generic.List <string>(); const int chunkSize = 5000; // Conservative chunk size < 65k characters. while (bodyTextOffset < bodyText.Length) { int readSize = chunkSize; readSize = bodyTextOffset + readSize >= bodyText.Length ? bodyText.Length - bodyTextOffset : readSize; bodyTextList.Add(bodyText.Substring(bodyTextOffset, readSize)); bodyTextOffset += readSize; } foreach (string bodyTextChunk in bodyTextList) { GUILayout.Label(bodyTextChunk, EditorStyles.wordWrappedLabel); } GUILayout.EndScrollView(); bool yesPressed = false; bool noPressed = false; GUILayout.BeginHorizontal(); if (yesText != "") { yesPressed = GUILayout.Button(yesText); } if (noText != "") { noPressed = GUILayout.Button(noText); } GUILayout.EndHorizontal(); GUILayout.EndVertical(); // If yes or no buttons were pressed, call the buttonClicked delegate. if (yesPressed || noPressed) { if (yesPressed) { result = true; } else if (noPressed) { result = false; } if (buttonClicked != null) { buttonClicked(this); } } }
void ShowLobby() { #region Waiting room GUI if (PhotonNetwork.room != null) { return; //Only when we're not in a Room } if (visualUI == false) { return; } GUILayout.BeginArea(new Rect((Screen.width - 400) / 2, (Screen.height - 300) / 2, 400, 300)); GUILayout.Label("Main Menu"); //Player name GUILayout.BeginHorizontal(); GUILayout.Label("Player name:", GUILayout.Width(150)); PhotonNetwork.playerName = GUILayout.TextField(PhotonNetwork.playerName); if (GUI.changed)//Save name { PlayerPrefs.SetString("playerName", PhotonNetwork.playerName); } GUILayout.EndHorizontal(); GUILayout.Space(15); //Join room by title GUILayout.BeginHorizontal(); GUILayout.Label("JOIN ROOM:", GUILayout.Width(150)); roomName = GUILayout.TextField(roomName); if (GUILayout.Button("GO")) { PhotonNetwork.JoinRoom(roomName); } GUILayout.EndHorizontal(); //Create a room (fails if exist!) GUILayout.BeginHorizontal(); GUILayout.Label("CREATE ROOM:", GUILayout.Width(150)); roomName = GUILayout.TextField(roomName); if (GUILayout.Button("GO")) { PhotonNetwork.CreateRoom(roomName, new RoomOptions() { MaxPlayers = 2, IsOpen = true, IsVisible = true }, null); } GUILayout.EndHorizontal(); //Join random room GUILayout.BeginHorizontal(); GUILayout.Label("JOIN RANDOM ROOM:", GUILayout.Width(150)); if (/*PhotonNetwork.GetRoomList().Length == 0*/ false) { GUILayout.Label("..no games available..."); } else { if (GUILayout.Button("GO")) { PhotonNetwork.JoinRandomRoom(); } } GUILayout.EndHorizontal(); GUILayout.Space(30); GUILayout.Label("ROOM LISTING:"); GUILayout.Space(30); GUILayout.Label("ROOM LISTING:"); if (PhotonNetwork.GetRoomList().Length == 0) { GUILayout.Label("..no games available.."); } else { //Room listing: simply call GetRoomList: no need to fetch/poll whatever! scrollPos = GUILayout.BeginScrollView(scrollPos); foreach (RoomInfo game in PhotonNetwork.GetRoomList()) { GUILayout.BeginHorizontal(); GUILayout.Label(game.name + " " + game.playerCount + "/" + game.maxPlayers); if (GUILayout.Button("JOIN")) { PhotonNetwork.JoinRoom(game.name); } GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); } GUILayout.EndArea(); #endregion }
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(); }
void RenderSpawnWindow(int windowID) { if (Event.current.type == EventType.Repaint) { spawnWindowRect.height = 0; } GUI.DragWindow(new Rect(0, 0, 10000, 20)); GUILayout.BeginVertical(); { GUILayout.BeginHorizontal(); { GUILayout.BeginVertical(); { int i = 0; foreach (String name in spawnableObjectNames) { if (i % 2 == 0) { if (GUILayout.Button(CreateDisplayName(name), GUILayout.Height(spawn_button_height), GUILayout.Width(spawn_column_width))) { SpawnObject(name, false); } } i++; } } GUILayout.EndVertical(); GUILayout.Space(spawn_middle_spacing_no_margin); GUILayout.BeginVertical(); { int i = 0; foreach (String name in spawnableObjectNames) { if (i % 2 != 0) { if (GUILayout.Button(CreateDisplayName(name), GUILayout.Height(spawn_button_height), GUILayout.Width(spawn_column_width))) { SpawnObject(name, false); } } i++; } } GUILayout.EndVertical(); } GUILayout.EndHorizontal(); GUILayout.Space(spawn_middle_spacing_no_margin); GUILayout.BeginHorizontal(); { customObjectName = GUILayout.TextField(customObjectName, GUILayout.Height(spawn_button_height)); GUILayout.Space(spawn_middle_spacing_no_margin); if (GUILayout.Button("Spawn", GUILayout.Height(spawn_button_height), GUILayout.Width(spawn_custom_button_width))) { SpawnObject(customObjectName, false); } } GUILayout.EndHorizontal(); if (placedGameObjects.Count > 0) { GUILayout.Label("Modify Spawned Item:", labelStyle); float maxHeight = Mathf.Min(208, placedGameObjects.Count * (spawn_button_height + button_margin_sides * 2) + (button_margin_sides * 2)); scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.Height(maxHeight), GUILayout.ExpandHeight(true)); { GUILayout.BeginVertical(); { foreach (GameObject gameObject in this.placedGameObjects) { if (GUILayout.Button(gameObject.name.Replace("(Clone)", ""), GUILayout.Height(spawn_button_height))) { SpawnObject(gameObject.name, true); } } } GUILayout.EndVertical(); } GUILayout.EndScrollView(); } GUILayout.Space(spawn_middle_spacing_no_margin); if (GUILayout.Button("Close", GUILayout.Height(spawn_button_height))) { HideSpawnMenu(); } } GUILayout.EndVertical(); }
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"); }
/// <summary> /// Draw the custom wizard. /// </summary> void OnGUI() { BetterList <UIDrawCall> dcs = UIDrawCall.activeList; dcs.Sort(delegate(UIDrawCall a, UIDrawCall b) { return(a.finalRenderQueue.CompareTo(b.finalRenderQueue)); }); if (dcs.size == 0) { EditorGUILayout.HelpBox("No NGUI draw calls present in the scene", MessageType.Info); return; } UIPanel selectedPanel = NGUITools.FindInParents <UIPanel>(Selection.activeGameObject); GUILayout.Space(12f); NGUIEditorTools.SetLabelWidth(100f); ShowFilter show = (NGUISettings.showAllDCs ? ShowFilter.AllPanels : ShowFilter.SelectedPanel); if ((ShowFilter)EditorGUILayout.EnumPopup("Draw Call Filter", show) != show) { NGUISettings.showAllDCs = !NGUISettings.showAllDCs; } GUILayout.Space(6f); if (selectedPanel == null && !NGUISettings.showAllDCs) { EditorGUILayout.HelpBox("No panel selected", MessageType.Info); return; } NGUIEditorTools.SetLabelWidth(80f); mScroll = GUILayout.BeginScrollView(mScroll); int dcCount = 0; for (int i = 0; i < dcs.size; ++i) { UIDrawCall dc = dcs[i]; string key = "Draw Call " + (i + 1); bool highlight = (selectedPanel == null || selectedPanel == dc.manager); if (!highlight) { if (!NGUISettings.showAllDCs) { continue; } if (UnityEditor.EditorPrefs.GetBool(key, true)) { GUI.color = new Color(0.85f, 0.85f, 0.85f); } else { GUI.contentColor = new Color(0.85f, 0.85f, 0.85f); } } else { GUI.contentColor = Color.white; } ++dcCount; string name = key + " of " + dcs.size; if (!dc.isActive) { name = name + " (HIDDEN)"; } else if (!highlight) { name = name + " (" + dc.manager.name + ")"; } if (NGUIEditorTools.DrawHeader(name, key)) { GUI.color = highlight ? Color.white : new Color(0.8f, 0.8f, 0.8f); NGUIEditorTools.BeginContents(); EditorGUILayout.ObjectField("Material", dc.dynamicMaterial, typeof(Material), false); int count = 0; for (int a = 0; a < UIPanel.list.Count; ++a) { UIPanel p = UIPanel.list[a]; for (int b = 0; b < p.widgets.Count; ++b) { UIWidget w = p.widgets[b]; if (w.drawCall == dc) { ++count; } } } string myPath = NGUITools.GetHierarchy(dc.manager.cachedGameObject); string remove = myPath + "\\"; string[] list = new string[count + 1]; list[0] = count.ToString(); count = 0; for (int a = 0; a < UIPanel.list.Count; ++a) { UIPanel p = UIPanel.list[a]; for (int b = 0; b < p.widgets.Count; ++b) { UIWidget w = p.widgets[b]; if (w.drawCall == dc) { string path = NGUITools.GetHierarchy(w.cachedGameObject); list[++count] = count + ". " + (string.Equals(path, myPath) ? w.name : path.Replace(remove, "")); } } } GUILayout.BeginHorizontal(); int sel = EditorGUILayout.Popup("Widgets", 0, list); NGUIEditorTools.DrawPadding(); GUILayout.EndHorizontal(); if (sel != 0) { count = 0; for (int a = 0; a < UIPanel.list.Count; ++a) { UIPanel p = UIPanel.list[a]; for (int b = 0; b < p.widgets.Count; ++b) { UIWidget w = p.widgets[b]; if (w.drawCall == dc && ++count == sel) { Selection.activeGameObject = w.gameObject; break; } } } } GUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Render Q", dc.finalRenderQueue.ToString(), GUILayout.Width(120f)); bool draw = (Visibility)EditorGUILayout.EnumPopup(dc.isActive ? Visibility.Visible : Visibility.Hidden) == Visibility.Visible; NGUIEditorTools.DrawPadding(); GUILayout.EndHorizontal(); if (dc.isActive != draw) { dc.isActive = draw; NGUITools.SetDirty(dc.manager); } GUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Triangles", dc.triangles.ToString(), GUILayout.Width(120f)); if (dc.manager != selectedPanel) { if (GUILayout.Button("Select the Panel")) { Selection.activeGameObject = dc.manager.gameObject; } NGUIEditorTools.DrawPadding(); } GUILayout.EndHorizontal(); if (dc.manager.clipping != UIDrawCall.Clipping.None && !dc.isClipped) { EditorGUILayout.HelpBox("You must switch this material's shader to Unlit/Transparent Colored or Unlit/Premultiplied Colored in order for clipping to work.", MessageType.Warning); } NGUIEditorTools.EndContents(); GUI.color = Color.white; } } if (dcCount == 0) { EditorGUILayout.HelpBox("No draw calls found", MessageType.Info); } GUILayout.EndScrollView(); }
//Calculations GUI core internal void Calculations() { #region Calculations //Selection mode GUIUtils.CreateTwinToggle("Calculations mode:", ref this.calcSelect, 300, new string[] { "Automatic", "Manual" }); GUILayout.Space(5); //Calculations this.parachuteScroll = GUILayout.BeginScrollView(this.parachuteScroll, false, false, this.skins.horizontalScrollbar, this.skins.verticalScrollbar, this.skins.box, GUILayout.Height(160)); string label; float max, min; #region Automatic if (this.calcSelect) { this.typeID = GUILayout.SelectionGrid(this.typeID, EnumUtils.GetNames <ParachuteType>(), 3, this.skins.button); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Toggle(this.getMass, "Use current craft mass", this.skins.button, GUILayout.Width(150))) { this.getMass = true; } GUILayout.FlexibleSpace(); if (GUILayout.Toggle(!this.getMass, "Input craft mass", this.skins.button, GUILayout.Width(150))) { this.getMass = false; } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); if (this.getMass) { GUILayout.Label("Currently using " + (this.useDry ? "dry mass" : "wet mass"), skins.label); if (GUILayout.Button("Switch to " + (this.useDry ? "wet mass" : "dry mass"), this.skins.button, GUILayout.Width(125))) { this.useDry = !this.useDry; } } else { GUIUtils.CreateEntryArea("Mass to use (t):", ref mass, 0.1f, 10000, 100); } max = 300; switch (this.type) { case ParachuteType.Main: label = "Wanted touchdown speed (m/s):"; break; case ParachuteType.Drogue: label = "Wanted speed at target alt (m/s):"; max = 5000; break; case ParachuteType.Drag: label = "Planned landing speed (m/s):"; break; default: label = string.Empty; break; } GUIUtils.CreateEntryArea(label, ref this.landingSpeed, 0.1f, max, 100); if (this.type == ParachuteType.Drogue) { GUIUtils.CreateEntryArea("Target altitude (m):", ref this.refDepAlt, 10, (float)body.GetMaxAtmosphereAltitude(), 100); } if (this.type == ParachuteType.Drag) { GUIUtils.CreateEntryArea("Wanted deceleration (m/s²):", ref this.deceleration, 0.1f, 100, 100); } GUIUtils.CreateEntryArea("Parachutes used (parachutes):", ref this.chuteCount, 1, 100, 100); } #endregion #region Manual else { float p, d; if (!float.TryParse(this.preDepDiam, out p)) { p = -1; } if (!float.TryParse(this.depDiam, out d)) { d = -1; } //Predeployed diameter GUIUtils.CreateEntryArea("Predeployed diameter (m):", ref this.preDepDiam, 0.5f, d, 100); if (p != -1) { GUILayout.Label("Resulting area: " + RCUtils.GetArea(p).ToString("0.00") + "m²", this.skins.label); } else { GUILayout.Label("Resulting predeployed area: --- m²", this.skins.label); } //Deployed diameter GUIUtils.CreateEntryArea("Deployed diameter (m):", ref this.depDiam, 1, (this.pChute.textures == null ? 70 : this.model.maxDiam), 100); if (d != 1) { GUILayout.Label("Resulting area: " + RCUtils.GetArea(d).ToString("0.00") + "m²", this.skins.label); } else { GUILayout.Label("Resulting deployed area: --- m²", this.skins.label); } } #endregion GUILayout.EndScrollView(); #endregion #region Specific //Pressure/alt toggle GUILayout.Space(5); GUILayout.BeginHorizontal(); if (GUILayout.Toggle(this.isPressure, "Pressure predeployment", this.skins.toggle)) { if (!this.isPressure) { this.isPressure = true; this.predepClause = this.parachute.minPressure.ToString(); } } GUILayout.FlexibleSpace(); if (GUILayout.Toggle(!this.isPressure, "Altitude predeployment", this.skins.toggle)) { if (this.isPressure) { this.isPressure = false; this.predepClause = this.parachute.minDeployment.ToString(); } } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); //Pressure/alt selection if (this.isPressure) { label = "Predeployment pressure (atm):"; min = 0.0001f; max = (float)this.body.GetPressureASL(); } else { label = "Predeployment altitude (m):"; min = 10; max = (float)body.GetMaxAtmosphereAltitude(); } GUIUtils.CreateEntryArea(label, ref this.predepClause, min, max); //Deployment altitude GUIUtils.CreateEntryArea("Deployment altitude", ref deploymentAlt, 10, (float)body.GetMaxAtmosphereAltitude()); //Cut altitude GUIUtils.CreateEmptyEntryArea("Autocut altitude (m):", ref this.cutAlt, -1, (float)this.body.GetMaxAtmosphereAltitude()); //Predeployment speed GUIUtils.CreateEntryArea("Pre deployment speed (s):", ref preDepSpeed, 0.5f, 5); //Deployment speed GUIUtils.CreateEntryArea("Deployment speed (s):", ref depSpeed, 1, 10); #endregion }