public static bool BeginWrapperWindow(this SerializedProperty property, float height = 32f, string themeName = "", string IconFileName = "", float reduceClicableWidth = 0f, string overrideLabel = "", float LabelXOffset = 0) { //try { if (InterfaceThemeConfig == null) { InterfaceThemeConfig = FileUtility.LoadFile(ThemeFileName) as ComboMasterInterfaceConfig; } ComboMasterInterfaceConfig.DepthTheme theme = themeName == "" ? InterfaceThemeConfig.CustomStyles[0] : InterfaceThemeConfig.GetCustomStyle(themeName); Texture2D icon = (Texture2D)FileUtility.LoadTexture(IconFileName); if (theme == null) { Debug.Log("Theme Error"); } GUILayout.BeginVertical(property.isExpanded ? theme.WindowOpennedHeaderStyle : theme.WindowClosedHeaderStyle); Rect label = EditorGUILayout.GetControlRect(false, height); label.x -= 12f; label.width += 12f; //Header block style: #region Header visible block label.x += LabelXOffset; GUI.Box(label, icon != null ? new GUIContent((overrideLabel == "" ? property.displayName : overrideLabel) + " ", icon) : new GUIContent((overrideLabel == "" ? property.displayName : overrideLabel), (Texture2D)FileUtility.LoadTexture("ClosedFoldIcon")), theme.HeaderLabelStyle); //label.x -= LabelXOffset; #endregion #region clicable button label.width += reduceClicableWidth - LabelXOffset; if (GUI.Button(label, "", GUIStyle.none)) { property.isExpanded = !property.isExpanded; } #endregion #region Sandwich GUIStyle sandwichStyle = new GUIStyle(); sandwichStyle.alignment = TextAnchor.MiddleRight; GUI.Box(label, new GUIContent(theme.MinimizeIcon), sandwichStyle); #endregion if (property.isExpanded) { EditorGUILayout.BeginVertical(theme.WindowInnerStyle); EditorGUILayout.BeginHorizontal(); GUILayout.Space(Margin.left); EditorGUILayout.BeginVertical(); GUILayout.Space(Margin.up); } // } catch { //Debug.Log("Error: "+property.name); // } return(property.isExpanded); }
public static void BeginVerticalStylized(string themeName = "") { if (defaultTheme == null) { if (SerializedPropertyExtensions.InterfaceThemeConfig == null) { SerializedPropertyExtensions.InterfaceThemeConfig = FileUtility.LoadFile(SerializedPropertyExtensions.ThemeFileName) as ComboMasterInterfaceConfig; } defaultTheme = themeName == "" ? SerializedPropertyExtensions.InterfaceThemeConfig.CustomStyles[0] : SerializedPropertyExtensions.InterfaceThemeConfig.GetCustomStyle(themeName); } EditorGUILayout.BeginVertical(defaultTheme.WindowOpennedHeaderStyle); }
public void Draw() { serializedObj.Update(); if (InterfaceThemeConfig == null) { InterfaceThemeConfig = FileUtility.LoadFile("ComboMasterTheme") as ComboMasterInterfaceConfig; } if (serializedObj == null) { ReloadSerializedProperties(); } InspectorBeautifierExtensions.ThemeFileName = "ComboMasterTheme"; if (comboMaster.InputSequences == null || comboMaster.InputSequences.Length != InputSequenceElements.Length || comboMaster.InputSequences.Length != InputSequencesProp.arraySize) { ReloadSerializedProperties(); } if (Math.Round(EditorStyles.label.normal.textColor.r, 2) == 0.7) { useDarkTheme = true; } else { useDarkTheme = false; } DGUI.Space(0f); if (configProp.BeginWrapperWindow(32f, useDarkTheme ? "Dark" : "Grey", "GearIcon")) { configProp.FindPropertyRelative("DigitalHorizontal").Draw(); configProp.FindPropertyRelative("DigitalVertical").Draw(); configProp.FindPropertyRelative("inversionDetection").Draw(); if (comboMaster.config.inversionDetection == CommandSequences.Config.InversionDetection.Manual) { serializedObj.FindProperty("FacingRight").Draw(); serializedObj.FindProperty("FacingUp").Draw(); } configProp.FindPropertyRelative("Player").Draw(); configProp.FindPropertyRelative("Debug").Draw(); } configProp.EndWrapperWindow(); //Economic interface mode ComboMasterInterfaceConfig.DepthTheme theme = InterfaceThemeConfig.GetCustomStyle(useDarkTheme ? "Dark" : "Grey"); Texture2D SequenceIcon = (Texture2D)FileUtility.LoadTexture("SequenceIcon"); GUIStyle BoldLabel = GUIStyle.none; BoldLabel.fontStyle = FontStyle.Bold; BoldLabel.fontSize = 12; DGUI.Space(0f); for (int i = 0; comboMaster.InputSequences != null && i < comboMaster.InputSequences.Length; i++) { GUILayout.BeginVertical(InputSequenceElements[i].isExpanded ? theme.WindowOpennedHeaderStyle : theme.WindowClosedHeaderStyle); Rect BlockRect = EditorGUILayout.GetControlRect(false, 32f); float fullwidth = BlockRect.width; BlockRect.x -= 12f; BlockRect.width += 12f; //Header block style: #region Header visible block GUI.Box(BlockRect, SequenceIcon, theme.HeaderLabelStyle); //label.x -= LabelXOffset; #endregion #region clicable button BlockRect.width = 32f; if (GUI.Button(BlockRect, "", GUIStyle.none)) { InputSequenceElements[i].isExpanded = !InputSequenceElements[i].isExpanded; } #endregion #region Sandwich if (InputSequenceElements[i].isExpanded) { //BlockRect.width = fullwidth; //GUIStyle sandwichStyle = new GUIStyle(); //sandwichStyle.alignment = TextAnchor.MiddleRight; //GUI.Box(BlockRect, new GUIContent(theme.MinimizeIcon), sandwichStyle); DrawMoveOrderingOptions(i, comboMaster, comboMaster.InputSequences[i], -13f, 13f); } else { DrawMoveOrderingOptions(i, comboMaster, comboMaster.InputSequences[i], -13f, 13f); } #endregion #region Editable Label BlockRect.width = fullwidth - 36f; BlockRect.xMin += 34f; // BlockRect.yMin += 10f; if (i >= comboMaster.InputSequences.Length) { return; } if (comboMaster.InputSequences[i].Name == "") { comboMaster.InputSequences[i].Name = "New Sequence"; } comboMaster.InputSequences[i].Name = EditorGUI.TextField(BlockRect, comboMaster.InputSequences[i].Name, theme.HeaderLabelStyle); #endregion #region Sequence Body if (InputSequenceElements[i].isExpanded) { EditorGUILayout.BeginVertical(theme.WindowInnerStyle); EditorGUILayout.BeginHorizontal(); GUILayout.Space(10f); EditorGUILayout.BeginVertical(); GUILayout.Space(10f); comboMaster.InputSequences[i].AutofitConnections(); DrawCommandSteps(InputSequenceElements[i].FindPropertyRelative("commandList"), ref comboMaster.InputSequences[i].commandList); } if (InputSequenceElements[i].isExpanded) { GUILayout.Space(10f); EditorGUILayout.EndVertical(); GUILayout.Space(10f); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); } EditorGUILayout.EndVertical(); DGUI.Space(0f); #endregion } InputSequencesProp.ArrayIncreaseButton(); DGUI.Space(0f); if (GUI.changed) { serializedObj.ApplyModifiedProperties(); if (!Application.isPlaying) { UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene()); } } }