public static void setSetting(QHierarchySetting setting, List <QHierarchyIconType> value) { string result = ""; for (int i = 0; i < value.Count; i++) { result += ((int)value[i]).ToString(); } setEditorSetting(setting, result); settings[(int)setting] = value; QHierarchy.repaint(); }
public static void setSetting(QHierarchySetting setting, List <QTagTexture> tagTextureList) { string result = ""; for (int i = 0; i < tagTextureList.Count; i++) { result += tagTextureList[i].tag + ";" + AssetDatabase.GetAssetPath(tagTextureList[i].texture.GetInstanceID()) + ";"; } setEditorSetting(setting, result); settings[(int)setting] = tagTextureList; QHierarchy.repaint(); }
void OnGUI() { bool fixedIconWidth = QHierarchySettings.getSetting <bool>(QHierarchySetting.FixedIconWidth); bool showErrorIcon = QHierarchySettings.getSetting <bool>(QHierarchySetting.ShowErrorIcon); bool showGameObjectIcon = QHierarchySettings.getSetting <bool>(QHierarchySetting.ShowGameObjectIcon); bool showTagAndLayerText = QHierarchySettings.getSetting <bool>(QHierarchySetting.ShowTagAndLayerText); bool showCustomTagIcon = QHierarchySettings.getSetting <bool>(QHierarchySetting.ShowCustomTagIcon); bool showLockButton = QHierarchySettings.getSetting <bool>(QHierarchySetting.ShowLockButton); bool showStaticIcon = QHierarchySettings.getSetting <bool>(QHierarchySetting.ShowStaticIcon); bool showMonoBehaviourIcon = QHierarchySettings.getSetting <bool>(QHierarchySetting.ShowMonoBehaviourIcon); scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition); { GUILayout.Space(5); if (drawTitle(QHierarchySetting.GeneralSettingsFoldout, " General Settings")) { bool showVisibilityButton = QHierarchySettings.getSetting <bool>(QHierarchySetting.ShowVisibilityButton); if (EditorGUILayout.ToggleLeft(" Show Visibility Button", showVisibilityButton) != showVisibilityButton) { QHierarchySettings.setSetting(QHierarchySetting.ShowVisibilityButton, !showVisibilityButton); } if (EditorGUILayout.ToggleLeft(" Show Lock Button", showLockButton) != showLockButton) { QHierarchySettings.setSetting(QHierarchySetting.ShowLockButton, !showLockButton); if (showLockButton) { QHierarchy.unlockAll(); } } bool showMeshButton = QHierarchySettings.getSetting <bool>(QHierarchySetting.ShowMeshButton); if (EditorGUILayout.ToggleLeft(" Show Renderer Button", showMeshButton) != showMeshButton) { QHierarchySettings.setSetting(QHierarchySetting.ShowMeshButton, !showMeshButton); } if (EditorGUILayout.ToggleLeft(" Show MonoBehavior Icon", showMonoBehaviourIcon) != showMonoBehaviourIcon) { QHierarchySettings.setSetting(QHierarchySetting.ShowMonoBehaviourIcon, !showMonoBehaviourIcon); } if (EditorGUILayout.ToggleLeft(" Show Error Icon", showErrorIcon) != showErrorIcon) { QHierarchySettings.setSetting(QHierarchySetting.ShowErrorIcon, !showErrorIcon); } if (EditorGUILayout.ToggleLeft(" Show Game Object icon", showGameObjectIcon) != showGameObjectIcon) { QHierarchySettings.setSetting(QHierarchySetting.ShowGameObjectIcon, !showGameObjectIcon); } if (EditorGUILayout.ToggleLeft(" Show Tag And Layer", showTagAndLayerText) != showTagAndLayerText) { QHierarchySettings.setSetting(QHierarchySetting.ShowTagAndLayerText, !showTagAndLayerText); } if (EditorGUILayout.ToggleLeft(" Show Custom Tag Icon", showCustomTagIcon) != showCustomTagIcon) { QHierarchySettings.setSetting(QHierarchySetting.ShowCustomTagIcon, !showCustomTagIcon); } if (EditorGUILayout.ToggleLeft(" Show Static Button", showStaticIcon) != showStaticIcon) { QHierarchySettings.setSetting(QHierarchySetting.ShowStaticIcon, !showStaticIcon); } } if (drawTitle(QHierarchySetting.AppearanceSettingsFoldout, " Appearance Settings")) { bool showTreeMap = QHierarchySettings.getSetting <bool>(QHierarchySetting.ShowTreeMap); if (EditorGUILayout.ToggleLeft(" Show Hierarchy Tree", showTreeMap) != showTreeMap) { QHierarchySettings.setSetting(QHierarchySetting.ShowTreeMap, !showTreeMap); } bool showHiddenObjectList = QHierarchySettings.getSetting <bool>(QHierarchySetting.ShowHiddenQHierarchyObjectList); if (EditorGUILayout.ToggleLeft(" Show QHierarchy GameObject", showHiddenObjectList) != showHiddenObjectList) { QHierarchySettings.setSetting(QHierarchySetting.ShowHiddenQHierarchyObjectList, !showHiddenObjectList); } bool showModifierWarning = QHierarchySettings.getSetting <bool>(QHierarchySetting.ShowModifierWarning); if (EditorGUILayout.ToggleLeft(" Show Warning When Using Modifier + Click", showModifierWarning) != showModifierWarning) { QHierarchySettings.setSetting(QHierarchySetting.ShowModifierWarning, !showModifierWarning); } if (EditorGUILayout.ToggleLeft(" Fixed Icons Width", fixedIconWidth) != fixedIconWidth) { fixedIconWidth = !fixedIconWidth; QHierarchySettings.setSetting(QHierarchySetting.FixedIconWidth, fixedIconWidth); if (fixedIconWidth) { QHierarchySettings.setSetting(QHierarchySetting.TagAndLayerSizeType, (int)QHierarchyTagAndLayerSizeType.Fixed); } } int identation = QHierarchySettings.getSetting <int>(QHierarchySetting.Identation); int newIdentation = EditorGUILayout.IntSlider(" Indentation", identation, 0, 200); if (newIdentation != identation) { QHierarchySettings.setSetting(QHierarchySetting.Identation, newIdentation); } } if (drawTitle(QHierarchySetting.OrderSettingsFoldout, " Order Settings")) { List <QHierarchyIconType> iconOrder = QHierarchySettings.getSetting <List <QHierarchyIconType> >(QHierarchySetting.IconOrder); for (int i = 0; i < iconOrder.Count; i++) { QHierarchyIconType type = iconOrder[i]; EditorGUILayout.BeginHorizontal(); { EditorGUILayout.LabelField((i + 1).ToString() + ".", GUILayout.Width(15)); Rect rect = EditorGUILayout.GetControlRect(GUILayout.Width(14), GUILayout.Height(14)); if (i > 0) { if (GUI.Button(rect, QHierarchyResource.getTexture(QHierarchyTexture.ButtonUp), GUIStyle.none)) { List <QHierarchyIconType> newIconOrder = new List <QHierarchyIconType>(); for (int j = 0; j < iconOrder.Count; j++) { if (j == i - 1) { newIconOrder.Add(iconOrder[i]); } else if (j == i) { newIconOrder.Add(iconOrder[i - 1]); } else { newIconOrder.Add(iconOrder[j]); } } QHierarchySettings.setSetting(QHierarchySetting.IconOrder, newIconOrder); } } rect.x += 18; if (i < iconOrder.Count - 1) { if (GUI.Button(rect, QHierarchyResource.getTexture(QHierarchyTexture.ButtonDown), GUIStyle.none)) { List <QHierarchyIconType> newIconOrder = new List <QHierarchyIconType>(); for (int j = 0; j < iconOrder.Count; j++) { if (j == i) { newIconOrder.Add(iconOrder[i + 1]); } else if (j == i + 1) { newIconOrder.Add(iconOrder[i]); } else { newIconOrder.Add(iconOrder[j]); } } QHierarchySettings.setSetting(QHierarchySetting.IconOrder, newIconOrder); } } rect.x += 16; rect.width = 200; rect.height = 20; GUI.Label(rect, addSpaces(type.ToString())); } EditorGUILayout.EndHorizontal(); } } if (showLockButton) { if (drawTitle(QHierarchySetting.LockSettingsFoldout, " Lock Settings")) { bool blockLockSelection = QHierarchySettings.getSetting <bool>(QHierarchySetting.PreventSelectionOfLockedObjects); if (EditorGUILayout.ToggleLeft(" Prevent selection of locked objects", blockLockSelection) != blockLockSelection) { QHierarchySettings.setSetting(QHierarchySetting.PreventSelectionOfLockedObjects, !blockLockSelection); } } } if (showMonoBehaviourIcon) { if (drawTitle(QHierarchySetting.MonoBehaviourIconFoldout, " MonoBehaviour Icon Settings")) { bool ignoreUnityMonobehaviour = QHierarchySettings.getSetting <bool>(QHierarchySetting.IgnoreUnityMonobehaviour); if (EditorGUILayout.ToggleLeft(" Ignore UnityEngine MonoBehaviours", ignoreUnityMonobehaviour) != ignoreUnityMonobehaviour) { QHierarchySettings.setSetting(QHierarchySetting.IgnoreUnityMonobehaviour, !ignoreUnityMonobehaviour); } } } if (showErrorIcon) { if (drawTitle(QHierarchySetting.ErrorIconSettingsFoldout, " Error Icon Settings")) { bool showErrorIconParent = QHierarchySettings.getSetting <bool>(QHierarchySetting.ShowErrorIconParent); if (EditorGUILayout.ToggleLeft(" Show error icon on parent game object", showErrorIconParent) != showErrorIconParent) { QHierarchySettings.setSetting(QHierarchySetting.ShowErrorIconParent, !showErrorIconParent); } bool showErrorForDisabledComponents = QHierarchySettings.getSetting <bool>(QHierarchySetting.ShowErrorForDisabledComponents); if (EditorGUILayout.ToggleLeft(" Show error for disabled components", showErrorForDisabledComponents) != showErrorForDisabledComponents) { QHierarchySettings.setSetting(QHierarchySetting.ShowErrorForDisabledComponents, !showErrorForDisabledComponents); } EditorGUILayout.Space(); EditorGUILayout.LabelField("Show the following error types:"); bool showErrorIconTypeScriptMissing = QHierarchySettings.getSetting <bool>(QHierarchySetting.ShowErrorIconScriptIsMissing); if (EditorGUILayout.ToggleLeft(" Script is missing", showErrorIconTypeScriptMissing) != showErrorIconTypeScriptMissing) { QHierarchySettings.setSetting(QHierarchySetting.ShowErrorIconScriptIsMissing, !showErrorIconTypeScriptMissing); } bool showErrorIconTypeReferenceIsNull = QHierarchySettings.getSetting <bool>(QHierarchySetting.ShowErrorIconReferenceIsNull); if (EditorGUILayout.ToggleLeft(" Reference is null", showErrorIconTypeReferenceIsNull) != showErrorIconTypeReferenceIsNull) { QHierarchySettings.setSetting(QHierarchySetting.ShowErrorIconReferenceIsNull, !showErrorIconTypeReferenceIsNull); } bool showErrorIconTypeStringIsEmpty = QHierarchySettings.getSetting <bool>(QHierarchySetting.ShowErrorIconStringIsEmpty); if (EditorGUILayout.ToggleLeft(" String is empty", showErrorIconTypeStringIsEmpty) != showErrorIconTypeStringIsEmpty) { QHierarchySettings.setSetting(QHierarchySetting.ShowErrorIconStringIsEmpty, !showErrorIconTypeStringIsEmpty); } } } if (showTagAndLayerText) { if (drawTitle(QHierarchySetting.TagAndLayerSettingsFoldout, " Tag And Layer Settings")) { QHierarchyTagAndLayerType tagAndLayerType = (QHierarchyTagAndLayerType)QHierarchySettings.getSetting <int>(QHierarchySetting.TagAndLayerType); QHierarchyTagAndLayerType newTagAndLayerType; if ((newTagAndLayerType = (QHierarchyTagAndLayerType)EditorGUILayout.EnumPopup("Show", tagAndLayerType)) != tagAndLayerType) { QHierarchySettings.setSetting(QHierarchySetting.TagAndLayerType, (int)newTagAndLayerType); } if (fixedIconWidth) { GUI.enabled = false; } QHierarchyTagAndLayerSizeType tagAndLayerSizeType = (QHierarchyTagAndLayerSizeType)QHierarchySettings.getSetting <int>(QHierarchySetting.TagAndLayerSizeType); QHierarchyTagAndLayerSizeType newTagAndLayerSizeType; if ((newTagAndLayerSizeType = (QHierarchyTagAndLayerSizeType)EditorGUILayout.EnumPopup("Layout", tagAndLayerSizeType)) != tagAndLayerSizeType) { QHierarchySettings.setSetting(QHierarchySetting.TagAndLayerSizeType, (int)newTagAndLayerSizeType); } if (fixedIconWidth) { GUI.enabled = true; } if (newTagAndLayerSizeType != QHierarchyTagAndLayerSizeType.Float) { QHierarchyTagAndLayerSizeValueType tagAndLayerSizeValueType = (QHierarchyTagAndLayerSizeValueType)QHierarchySettings.getSetting <int>(QHierarchySetting.TagAndLayerSizeValueType); QHierarchyTagAndLayerSizeValueType newTagAndLayerSizeValueType; if ((newTagAndLayerSizeValueType = (QHierarchyTagAndLayerSizeValueType)EditorGUILayout.EnumPopup("Type", tagAndLayerSizeValueType)) != tagAndLayerSizeValueType) { QHierarchySettings.setSetting(QHierarchySetting.TagAndLayerSizeValueType, (int)newTagAndLayerSizeValueType); } if (newTagAndLayerSizeValueType == QHierarchyTagAndLayerSizeValueType.Pixel) { int tagAndLayerSizeValue = QHierarchySettings.getSetting <int>(QHierarchySetting.TagAndLayerSizeValue); int newLayerSizeValue = EditorGUILayout.IntSlider("Pixel Width", tagAndLayerSizeValue, 1, 250); if (newLayerSizeValue != tagAndLayerSizeValue) { QHierarchySettings.setSetting(QHierarchySetting.TagAndLayerSizeValue, newLayerSizeValue); } } else { float tagAndLayerSizeValuePercent = QHierarchySettings.getSetting <float>(QHierarchySetting.TagAndLayerSizeValuePercent); float newtagAndLayerSizeValuePercent = EditorGUILayout.Slider("Percent Width", tagAndLayerSizeValuePercent, 0, 0.5f); if (tagAndLayerSizeValuePercent != newtagAndLayerSizeValuePercent) { QHierarchySettings.setSetting(QHierarchySetting.TagAndLayerSizeValuePercent, newtagAndLayerSizeValuePercent); } } QHierarchyTagAndLayerAligment tagAndLayerAligment = (QHierarchyTagAndLayerAligment)QHierarchySettings.getSetting <int>(QHierarchySetting.TagAndLayerAligment); QHierarchyTagAndLayerAligment newTagAndLayerAligment; if ((newTagAndLayerAligment = (QHierarchyTagAndLayerAligment)EditorGUILayout.EnumPopup("Alignment", tagAndLayerAligment)) != tagAndLayerAligment) { QHierarchySettings.setSetting(QHierarchySetting.TagAndLayerAligment, (int)newTagAndLayerAligment); } } } } if (showCustomTagIcon) { if (drawTitle(QHierarchySetting.CustomTagIconFoldout, " Custom Tag Icon")) { bool replaceGameObjectIcon = QHierarchySettings.getSetting <bool>(QHierarchySetting.CustomTagIconReplace); if (EditorGUILayout.ToggleLeft(" Replace Game Object Icon", replaceGameObjectIcon) != replaceGameObjectIcon) { QHierarchySettings.setSetting(QHierarchySetting.CustomTagIconReplace, !replaceGameObjectIcon); } bool customTagIconTextureListFoldout = QHierarchySettings.getSetting <bool>(QHierarchySetting.CustomTagIconTextureListFoldout); bool customTagIconTextureListFoldoutNew = EditorGUILayout.Foldout(customTagIconTextureListFoldout, " Custom Tag Icon Texture List"); if (customTagIconTextureListFoldoutNew != customTagIconTextureListFoldout) { QHierarchySettings.setSetting(QHierarchySetting.CustomTagIconTextureListFoldout, customTagIconTextureListFoldoutNew); } if (customTagIconTextureListFoldoutNew) { EditorGUI.indentLevel++; drawTagTextureList(); EditorGUI.indentLevel--; } } } EditorGUILayout.Space(); } EditorGUILayout.EndScrollView(); }
static void init() { hierarchy = new QHierarchy(); }
public static void setSetting(QHierarchySetting setting, float value) { setEditorSetting(setting, value); settings[(int)setting] = value; QHierarchy.repaint(); }