static void HandleColorPreferences(string searchContext) { EditorGUI.BeginChangeCheck(); s_UseUnityColors.value = SettingsGUILayout.SettingsToggle("Use Unity Colors", s_UseUnityColors, searchContext); if (!s_UseUnityColors.value) { using (new SettingsGUILayout.IndentedGroup()) { s_DitherFaceHandle.value = SettingsGUILayout.SettingsToggle("Dither Face Overlay", s_DitherFaceHandle, searchContext); s_WireframeColorPref.value = SettingsGUILayout.SettingsColorField("Wireframe", s_WireframeColorPref, searchContext); s_PreselectionColorPref.value = SettingsGUILayout.SettingsColorField("Preselection", s_PreselectionColorPref, searchContext); s_SelectedFaceColorPref.value = SettingsGUILayout.SettingsColorField("Selected Face Color", s_SelectedFaceColorPref, searchContext); s_UnselectedEdgeColorPref.value = SettingsGUILayout.SettingsColorField("Unselected Edge Color", s_UnselectedEdgeColorPref, searchContext); s_SelectedEdgeColorPref.value = SettingsGUILayout.SettingsColorField("Selected Edge Color", s_SelectedEdgeColorPref, searchContext); s_UnselectedVertexColorPref.value = SettingsGUILayout.SettingsColorField("Unselected Vertex Color", s_UnselectedVertexColorPref, searchContext); s_SelectedVertexColorPref.value = SettingsGUILayout.SettingsColorField("Selected Vertex Color", s_SelectedVertexColorPref, searchContext); } } s_DepthTestHandles.value = SettingsGUILayout.SettingsToggle("Depth Test", s_DepthTestHandles, searchContext); s_VertexPointSize.value = SettingsGUILayout.SettingsSlider("Vertex Size", s_VertexPointSize, 1f, 10f, searchContext); s_EdgeLineSize.value = SettingsGUILayout.SettingsSlider("Line Size", s_EdgeLineSize, 0f, 10f, searchContext); s_WireframeLineSize.value = SettingsGUILayout.SettingsSlider("Wireframe Size", s_WireframeLineSize, 0f, 10f, searchContext); if (EditorGUI.EndChangeCheck()) { ProBuilderEditor.UpdateMeshHandles(true); } }
static void ConditionalValueGUI(string searchContext) { EditorGUI.BeginChangeCheck(); s_NumberWithSlider.value = SettingsGUILayout.SettingsSlider("Number With Slider", s_NumberWithSlider, 0, 10, searchContext); var foo = s_Foo.value; using (new SettingsGUILayout.IndentedGroup("Foo Class")) { EditorGUI.BeginChangeCheck(); foo.intValue = SettingsGUILayout.SearchableIntField("Int Value", foo.intValue, searchContext); foo.stringValue = SettingsGUILayout.SearchableTextField("String Value", foo.stringValue, searchContext); // Because FooClass is a reference type, we need to apply the changes to the backing repository (SetValue // would also work here). if (EditorGUI.EndChangeCheck()) { s_Foo.ApplyModifiedProperties(); } } SettingsGUILayout.DoResetContextMenuForLastRect(s_Foo); if (EditorGUI.EndChangeCheck()) { MySettingsManager.Save(); } }
static void ShortcutSettings(string searchContext) { if (!string.IsNullOrEmpty(searchContext)) { return; } s_Shortcuts = ProBuilderEditor.s_Shortcuts; if (s_Shortcuts == null || s_Shortcuts.Length < 1) { ProBuilderEditor.s_Shortcuts.SetValue(s_Shortcuts = Shortcut.DefaultShortcuts().ToArray(), true); } GUILayout.BeginHorizontal(); GUILayout.BeginVertical(GUILayout.Width(EditorGUIUtility.labelWidth)); ShortcutSelectPanel(); GUILayout.EndVertical(); GUILayout.BeginVertical(); ShortcutEditPanel(); GUILayout.EndVertical(); GUILayout.EndHorizontal(); SettingsGUILayout.DoResetContextMenuForLastRect(ProBuilderEditor.s_Shortcuts); }
private static void ColorDefaults(string searchContext) { EditorGUI.BeginChangeCheck(); GUILayout.Space(2f); colorList.DoLayoutList(); SettingsGUILayout.DoResetContextMenuForLastRect(uvColorDefaults); if (EditorGUI.EndChangeCheck()) { uvColorDefaults.ApplyModifiedProperties(); } }
private static void DrawGeneralBlock(string searchContext) { if (BuildManagerUtility.TryMatchSearch(searchContext, ShowUserPreferencesLabel.text)) { if (GUILayout.Button(ShowUserPreferencesLabel)) { SettingsService.OpenUserPreferences(BuildManagerUtility.UserPreferencesPath); } EditorGUILayout.Separator(); } if (ShowSplashScreenSetting != BoolState.Null) { PlayerSettings.SplashScreen.show = ShowSplashScreen; } if (ShowUnityLogoSetting != BoolState.Null) { PlayerSettings.SplashScreen.showUnityLogo = ShowUnityLogo; } using (EditorGUI.ChangeCheckScope changeCheckScope = new EditorGUI.ChangeCheckScope()) { UseProjectFolderAsBuildNameSetting.value = SettingsGUILayout.SettingsToggle(UseProjectFolderAsBuildNameLabel, UseProjectFolderAsBuildNameSetting, searchContext); BuildManagerUtility.DrawBoolStateField(searchContext, ShowSplashScreenLabel, ShowSplashScreenSetting, PlayerSettings.SplashScreen.show, delegate { PlayerSettings.SplashScreen.show = ShowSplashScreen; }); using (new EditorGUI.IndentLevelScope()) { using (new EditorGUI.DisabledScope(!ShowSplashScreen)) { BuildManagerUtility.DrawBoolStateField(searchContext, ShowUnityLogoLabel, ShowUnityLogoSetting, PlayerSettings.SplashScreen.showUnityLogo, delegate { PlayerSettings.SplashScreen.showUnityLogo = ShowUnityLogo; }); } } UseUtcNowAsIosBuildNumberSetting.value = SettingsGUILayout.SettingsToggle(UseUtcNowAsIosBuildNumberLabel, UseUtcNowAsIosBuildNumberSetting, searchContext); UseUtcNowAsMacBuildNumberSetting.value = SettingsGUILayout.SettingsToggle(UseUtcNowAsMacBuildNumberLabel, UseUtcNowAsMacBuildNumberSetting, searchContext); if (changeCheckScope.changed) { Settings.Save(); } } }
private static void GraphZoomSettings(string searchContext) { EditorGUI.BeginChangeCheck(); zoomSpeed.value = SettingsGUILayout.SettingsSlider("Speed", zoomSpeed, -1f, 1f, searchContext); minZoom.value = SettingsGUILayout.SettingsSlider("Minimum", minZoom, 0.01f, 1f, searchContext); maxZoom.value = SettingsGUILayout.SettingsSlider("Maximum", maxZoom, 1f, 100f, searchContext); if (EditorGUI.EndChangeCheck()) { zoomSpeed.ApplyModifiedProperties(); minZoom.ApplyModifiedProperties(); maxZoom.ApplyModifiedProperties(); } }
private static void XamlC(string search) { EditorGUI.BeginChangeCheck(); using (new SettingsGUILayout.IndentedGroup("XamlC")) { OptimizeIL.value = SettingsGUILayout.SettingsToggle("Optimize IL", OptimizeIL, search); DebugSymbols.value = SettingsGUILayout.SettingsToggle("Debug Symbols", DebugSymbols, search); } if (EditorGUI.EndChangeCheck()) { Backend.Save(); } }
static void ExperimentalFeaturesSettings(string searchContext) { s_ExperimentalFeatures.value = SettingsGUILayout.SettingsToggle("Experimental Features Enabled", s_ExperimentalFeatures, searchContext); if (s_ExperimentalFeatures.value) { using (new SettingsGUILayout.IndentedGroup()) { s_MeshesAreAssets.value = SettingsGUILayout.SettingsToggle("Store Mesh as Asset", s_MeshesAreAssets, searchContext); if (s_MeshesAreAssets.value) { EditorGUILayout.HelpBox("Please note that this feature is untested, and may result in instabilities or lost work. Proceed with caution!", MessageType.Warning); } } } }
private static void DrawCloudBuildsBlock(string searchContext) { using (EditorGUI.ChangeCheckScope changeCheckScope = new EditorGUI.ChangeCheckScope()) { AppendBuildNumberToVersionSetting.value = SettingsGUILayout.SettingsToggle(AppendBuildNumberToVersionLabel, AppendBuildNumberToVersionSetting, searchContext); using (new EditorGUI.IndentLevelScope()) { using (new EditorGUI.DisabledScope(!AppendBuildNumberToVersionSetting)) { if (BuildManagerUtility.TryMatchSearch(searchContext, BuildNumberExpressionLabel.text)) { BuildNumberExpressionSetting.value = EditorGUILayout.TextField(BuildNumberExpressionLabel, BuildNumberExpressionSetting); SettingsGUILayout.DoResetContextMenuForLastRect(BuildNumberExpressionSetting); Rect position = EditorGUILayout.GetControlRect(true); position.xMin += EditorGUIUtility.labelWidth; if (GUI.Button(position, "Validate")) { string buildNumber = Random.Range(1, 100).ToString(); string original = BuildNumberExpressionSetting; string replaced = original.Replace(BuildNumberPlaceholder, buildNumber); if (ExpressionEvaluator.Evaluate(replaced, out int result)) { Debug.Log($"Expression ({original}) is valid! Validated with Build Number {buildNumber}: ({replaced})={result}"); } else { Debug.LogError($"({original}) is not a valid expression!"); } } } } } UseBuildStartTimeAsUtcNowSetting.value = SettingsGUILayout.SettingsToggle(UseBuildStartTimeAsUtcNowLabel, UseBuildStartTimeAsUtcNowSetting, searchContext); SumBuildNumberToBundleVersionCodeSetting.value = SettingsGUILayout.SettingsToggle(SumBuildNumberToBundleVersionCodeLabel, SumBuildNumberToBundleVersionCodeSetting, searchContext); if (changeCheckScope.changed) { Settings.Save(); } } }
/// <summary> /// Draw a searchable color field with a reset button for a color setting /// </summary> /// <param name="property">The setting property of the target setting</param> /// <param name="origColor">The original color value</param> /// <param name="searchContext">The search context</param> /// <returns> /// The specified color in the color field /// </returns> private static Color ColorProperty( SettingsProperty <Color> property, Color origColor, string searchContext) { var color = origColor; using (new EditorGUILayout.HorizontalScope()) { color = SettingsGUILayout.SearchableColorField( new GUIContent(property.label, property.tooltip), color, searchContext); if (GUILayout.Button("Reset", GUILayout.Width(50))) { color = property.defaultValue; } } return(color); }
static void UnwrapSettingDefaults(string searchContext) { Styles.Init(); var isSearching = !string.IsNullOrEmpty(searchContext); if (!isSearching) { Styles.unwrapSettingsFoldout = EditorGUILayout.Foldout(Styles.unwrapSettingsFoldout, "Lightmap UVs Settings"); } if (isSearching || Styles.unwrapSettingsFoldout) { EditorGUI.BeginChangeCheck(); var unwrap = (UnwrapParameters)s_UnwrapParameters; using (new SettingsGUILayout.IndentedGroup()) { unwrap.hardAngle = SettingsGUILayout.SearchableSlider(Styles.hardAngle, unwrap.hardAngle, 1f, 180f, searchContext); unwrap.packMargin = SettingsGUILayout.SearchableSlider(Styles.packMargin, unwrap.packMargin, 1f, 64f, searchContext); unwrap.angleError = SettingsGUILayout.SearchableSlider(Styles.angleError, unwrap.angleError, 1f, 75f, searchContext); unwrap.areaError = SettingsGUILayout.SearchableSlider(Styles.areaError, unwrap.areaError, 1f, 75f, searchContext); if (!isSearching) { GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Reset", Styles.miniButton)) { unwrap.Reset(); } GUILayout.EndHorizontal(); } } SettingsGUILayout.DoResetContextMenuForLastRect(s_UnwrapParameters); if (EditorGUI.EndChangeCheck()) { s_UnwrapParameters.value = unwrap; } } }
internal static void DrawBoolStateField(string searchContext, GUIContent label, UserSetting <BoolState> userSetting, bool defaultValue, Action onChanged) { if (!TryMatchSearch(searchContext, label.text)) { return; } using (EditorGUI.ChangeCheckScope changeCheckScope = new EditorGUI.ChangeCheckScope()) { BoolState value = EditorGUILayout.Toggle(label, userSetting.value.GetOrDefault(defaultValue)) ? BoolState.True : BoolState.False; if (changeCheckScope.changed) { userSetting.value = value; onChanged?.Invoke(); } SettingsGUILayout.DoResetContextMenuForLastRect(userSetting); } }
internal static void DrawEnumField <T>(string searchContext, GUIContent label, UserSetting <T> userSetting, Action onChanged) where T : Enum { if (!TryMatchSearch(searchContext, label.text)) { return; } using (EditorGUI.ChangeCheckScope changeCheckScope = new EditorGUI.ChangeCheckScope()) { T value = (T)EditorGUILayout.EnumPopup(label, userSetting); if (changeCheckScope.changed) { userSetting.value = value; onChanged?.Invoke(); } SettingsGUILayout.DoResetContextMenuForLastRect(userSetting); } }
private static void DrawLocalBuildsBlock(string searchContext) { using (EditorGUI.ChangeCheckScope changeCheckScope = new EditorGUI.ChangeCheckScope()) { AllowFallbackToMonoSetting.value = SettingsGUILayout.SettingsToggle(AllowFallbackToMonoLabel, AllowFallbackToMonoSetting, searchContext); using (new EditorGUI.IndentLevelScope()) { using (new EditorGUI.DisabledScope(!AllowFallbackToMonoSetting)) { BuildManagerUtility.DrawEnumField(searchContext, PreferredLinuxScriptingBackendLabel, PreferredLinuxScriptingBackendSetting, null); BuildManagerUtility.DrawEnumField(searchContext, PreferredMacScriptingBackendLabel, PreferredMacScriptingBackendSetting, null); BuildManagerUtility.DrawEnumField(searchContext, PreferredWindowsScriptingBackendLabel, PreferredWindowsScriptingBackendSetting, null); } } if (changeCheckScope.changed) { Settings.Save(); } } }
static void HandleColorPreferences(string searchContext) { s_UseUnityColors.value = SettingsGUILayout.SettingsToggle("Use Unity Colors", s_UseUnityColors, searchContext); if (!s_UseUnityColors.value) { using (new SettingsGUILayout.IndentedGroup()) { s_DitherFaceHandle.value = SettingsGUILayout.SettingsToggle("Dither Face Overlay", s_DitherFaceHandle, searchContext); s_WireframeColorPref.value = SettingsGUILayout.SettingsColorField("Wireframe", s_WireframeColorPref, searchContext); s_PreselectionColorPref.value = SettingsGUILayout.SettingsColorField("Preselection", s_PreselectionColorPref, searchContext); s_SelectedFaceColorPref.value = SettingsGUILayout.SettingsColorField("Selected Face Color", s_SelectedFaceColorPref, searchContext); s_UnselectedEdgeColorPref.value = SettingsGUILayout.SettingsColorField("Unselected Edge Color", s_UnselectedEdgeColorPref, searchContext); s_SelectedEdgeColorPref.value = SettingsGUILayout.SettingsColorField("Selected Edge Color", s_SelectedEdgeColorPref, searchContext); s_UnselectedVertexColorPref.value = SettingsGUILayout.SettingsColorField("Unselected Vertex Color", s_UnselectedVertexColorPref, searchContext); s_SelectedVertexColorPref.value = SettingsGUILayout.SettingsColorField("Selected Vertex Color", s_SelectedVertexColorPref, searchContext); } } s_DepthTestHandles.value = SettingsGUILayout.SettingsToggle("Depth Test", s_DepthTestHandles, searchContext); s_VertexPointSize.value = SettingsGUILayout.SettingsSlider("Vertex Size", s_VertexPointSize, 1f, 10f, searchContext); bool geoLine = BuiltinMaterials.geometryShadersSupported; if (geoLine) { s_EdgeLineSize.value = SettingsGUILayout.SettingsSlider("Line Size", s_EdgeLineSize, 0f, 3f, searchContext); s_WireframeLineSize.value = SettingsGUILayout.SettingsSlider("Wireframe Size", s_WireframeLineSize, 0f, 3f, searchContext); } else { GUI.enabled = false; SettingsGUILayout.SearchableSlider("Line Size", 0f, 0f, 3f, searchContext); SettingsGUILayout.SearchableSlider("Wireframe Size", 0f, 0f, 3f, searchContext); GUI.enabled = true; } }
private static void OnGUI(string searchContext) { var style = new GUIStyle(EditorStyles.helpBox); style.fontSize = 13; style.richText = true; EditorGUI.BeginChangeCheck(); _EnableCustomTitle.value = SettingsGUILayout.SettingsToggle("Enable Custom Window Title", _EnableCustomTitle, searchContext); using (new EditorGUI.DisabledScope(!_EnableCustomTitle.value)) { _FormatString.value = SettingsGUILayout.SettingsTextField("Window Title Format String", _FormatString, searchContext); _RepositoryPath.value = SettingsGUILayout.SettingsTextField( new GUIContent("Git Repository Path", "Git repository root directory"), _RepositoryPath, searchContext); var parametersInfoBox = $@"Available title parameters: • <Branch> {_DisabledTextColorTag}{TitleFormatter.Format("<Branch>")}</color> • <SceneName> {_DisabledTextColorTag}{TitleFormatter.Format("<SceneName>")}</color> • <ProjectName> {_DisabledTextColorTag}{TitleFormatter.Format("<ProjectName>")}</color> • <RepoDirName> {_DisabledTextColorTag}{TitleFormatter.Format("<RepoDirName>")}</color> • <ProjectPath> {_DisabledTextColorTag}{TitleFormatter.Format("<ProjectPath>")}</color> • <RepoPath> {_DisabledTextColorTag}{TitleFormatter.Format("<RepoPath>")}</color> • <EditorVersion> {_DisabledTextColorTag}{TitleFormatter.Format("<EditorVersion>")}</color> • <TargetPlatform> {_DisabledTextColorTag}{TitleFormatter.Format("<TargetPlatform>")}</color>"; GUILayout.Label(parametersInfoBox, style); } if (EditorGUI.EndChangeCheck()) { Instance.Save(); UpdateWindowTitle(); } }
private static void DrawHeaderBlock(string searchContext) { if (BuildManagerUtility.TryMatchSearch(searchContext, ShowProjectSettingsLabel.text)) { if (GUILayout.Button(ShowProjectSettingsLabel)) { SettingsService.OpenProjectSettings(BuildManagerUtility.ProjectSettingsPath); } EditorGUILayout.Separator(); } using (EditorGUI.ChangeCheckScope changeCheckScope = new EditorGUI.ChangeCheckScope()) { if (BuildManagerUtility.TryMatchSearch(searchContext, OpenBuiltPlayerOptionsLabel.text)) { OpenBuiltPlayerOptionsSetting.value = (OpenBuiltPlayerOptions)EditorGUILayout.EnumFlagsField(OpenBuiltPlayerOptionsLabel, OpenBuiltPlayerOptionsSetting); SettingsGUILayout.DoResetContextMenuForLastRect(OpenBuiltPlayerOptionsSetting); } CreateStandardizedBuildOutputSetting.value = SettingsGUILayout.SettingsToggle(CreateStandardizedBuildOutputLabel, CreateStandardizedBuildOutputSetting, searchContext); if (changeCheckScope.changed) { Settings.Save(); } } using (new EditorGUI.DisabledScope(!CreateStandardizedBuildOutputSetting)) { using (EditorGUI.ChangeCheckScope changeCheckScope = new EditorGUI.ChangeCheckScope()) { using (new EditorGUI.IndentLevelScope()) { GroupByBuildNameSetting.value = SettingsGUILayout.SettingsToggle(GroupByBuildNameLabel, GroupByBuildNameSetting, searchContext); GroupByBuildTargetSetting.value = SettingsGUILayout.SettingsToggle(GroupByBuildTargetLabel, GroupByBuildTargetSetting, searchContext); if (changeCheckScope.changed) { Settings.Save(); } if (!BuildManagerUtility.TryMatchSearch(searchContext, StandardizedBuildOutputPathLabel.text) && !BuildManagerUtility.TryMatchSearch(searchContext, ChangeButtonLabel.text)) { return; } Rect position = EditorGUILayout.GetControlRect(); position = EditorGUI.PrefixLabel(position, StandardizedBuildOutputPathLabel); if (GUI.Button(position, ChangeButtonLabel, EditorStyles.miniButton)) { string value = EditorUtility.OpenFolderPanel("Builds folder location", Path.GetDirectoryName(StandardizedBuildOutputPath), Path.GetFileName(StandardizedBuildOutputPath)); if (string.IsNullOrEmpty(value) == false) { StandardizedBuildOutputPathSetting.SetValue(value, true); } } SettingsGUILayout.DoResetContextMenuForLastRect(StandardizedBuildOutputPathSetting); position = EditorGUILayout.GetControlRect(); if (Event.current.type == EventType.MouseUp && Event.current.button == 0 && position.Contains(Event.current.mousePosition)) { string path = Directory.Exists(StandardizedBuildOutputPath) ? StandardizedBuildOutputPath : Path.GetDirectoryName(Application.dataPath); Assert.IsFalse(string.IsNullOrWhiteSpace(path)); Process.Start(path); } string outputLabel = StandardizedBuildOutputPathSetting == DefaultStandardizedBuildOutputPath ? $"./{DefaultStandardizedBuildOutputPath}" : StandardizedBuildOutputPath; EditorGUI.LabelField(position, outputLabel, EditorStyles.miniLabel); SettingsGUILayout.DoResetContextMenuForLastRect(StandardizedBuildOutputPathSetting); } } } }
static void PickingPreferences(string searchContext) { s_PickingDistance.value = SettingsGUILayout.SearchableSlider( new GUIContent("Picking Distance", "Distance to an object before it's considered hovered."), s_PickingDistance.value, 1, 150, searchContext); }
static void HandleBrushPreferences(string searchContext) { s_VertexBillboardSize.value = SettingsGUILayout.SettingsSlider(new GUIContent("Vertex Render Size", "The size at which selected vertices will be rendered."), s_VertexBillboardSize, 0f, 10f, searchContext); }
static bool DrawToggle(BaseSetting <bool> value, string searchContext) { return(SettingsGUILayout.SettingsToggle(value.GetGuiContent(), value, searchContext)); }