static float drawCustomTagIcon(GameObject gameObject, Rect rect) { bool fixedIconWidth = QHierarchySettings.getSetting <bool>(QHierarchySetting.FixedIconWidth); rect.x -= 18; rect.width = 18; string gameObjectTag = gameObject.tag; QTagTexture tagTexture = QHierarchySettings.getSetting <List <QTagTexture> >(QHierarchySetting.CustomTagIcon).Find(t => t.tag == gameObjectTag); if (tagTexture != null) { EditorGUI.DrawRect(rect, backgroundColor); rect.width = 16; GUI.DrawTexture(rect, tagTexture.texture, ScaleMode.ScaleToFit, true); return(18); } else if (fixedIconWidth) { if (!QHierarchySettings.getSetting <bool>(QHierarchySetting.CustomTagIconReplace)) { EditorGUI.DrawRect(rect, backgroundColor); } return(18); } return(0); }
private void drawTagTextureList() { bool changed = false; List <QTagTexture> tagTextureList = QHierarchySettings.getSetting <List <QTagTexture> >(QHierarchySetting.CustomTagIcon); for (int i = 0; i < UnityEditorInternal.InternalEditorUtility.tags.Length; i++) { string tag = UnityEditorInternal.InternalEditorUtility.tags[i]; QTagTexture tagTexture = tagTextureList.Find(t => t.tag == tag); Texture2D newTexture = (Texture2D)EditorGUILayout.ObjectField(tag, tagTexture == null ? null : tagTexture.texture, typeof(Texture2D), false, GUILayout.MaxHeight(16)); if (newTexture != null && tagTexture == null) { QTagTexture newTagTexture = new QTagTexture(tag, newTexture); tagTextureList.Add(newTagTexture); changed = true; } else if (newTexture == null && tagTexture != null) { tagTextureList.Remove(tagTexture); changed = true; } else if (tagTexture != null && tagTexture.texture != newTexture) { tagTexture.texture = newTexture; changed = true; } } if (changed) { QHierarchySettings.setSetting(QHierarchySetting.CustomTagIcon, tagTextureList); EditorApplication.RepaintHierarchyWindow(); } }
static QHierarchySettings() { settings = new Dictionary <int, object>(); settings[(int)QHierarchySetting.ShowVisibilityButton] = getEditorSetting(QHierarchySetting.ShowVisibilityButton, true); settings[(int)QHierarchySetting.ShowLockButton] = getEditorSetting(QHierarchySetting.ShowLockButton, true); settings[(int)QHierarchySetting.ShowGameObjectIcon] = getEditorSetting(QHierarchySetting.ShowGameObjectIcon, true); settings[(int)QHierarchySetting.ShowTreeMap] = getEditorSetting(QHierarchySetting.ShowTreeMap, true); settings[(int)QHierarchySetting.ShowMonoBehaviourIcon] = getEditorSetting(QHierarchySetting.ShowMonoBehaviourIcon, true); settings[(int)QHierarchySetting.ShowTagAndLayerText] = getEditorSetting(QHierarchySetting.ShowTagAndLayerText, true); settings[(int)QHierarchySetting.ShowErrorIcon] = getEditorSetting(QHierarchySetting.ShowErrorIcon, true); settings[(int)QHierarchySetting.ShowErrorIconParent] = getEditorSetting(QHierarchySetting.ShowErrorIconParent, true); settings[(int)QHierarchySetting.ShowErrorIconScriptIsMissing] = getEditorSetting(QHierarchySetting.ShowErrorIconScriptIsMissing, true); settings[(int)QHierarchySetting.ShowErrorIconReferenceIsNull] = getEditorSetting(QHierarchySetting.ShowErrorIconReferenceIsNull, false); settings[(int)QHierarchySetting.ShowErrorIconStringIsEmpty] = getEditorSetting(QHierarchySetting.ShowErrorIconStringIsEmpty, false); settings[(int)QHierarchySetting.FixedIconWidth] = getEditorSetting(QHierarchySetting.FixedIconWidth, true); settings[(int)QHierarchySetting.TagAndLayerType] = getEditorSetting(QHierarchySetting.TagAndLayerType, 1); settings[(int)QHierarchySetting.TagAndLayerSizeType] = getEditorSetting(QHierarchySetting.TagAndLayerSizeType, 0); settings[(int)QHierarchySetting.TagAndLayerSizeValue] = getEditorSetting(QHierarchySetting.TagAndLayerSizeValue, 50); settings[(int)QHierarchySetting.TagAndLayerAligment] = getEditorSetting(QHierarchySetting.TagAndLayerAligment, 0); settings[(int)QHierarchySetting.TagAndLayerSizeValueType] = getEditorSetting(QHierarchySetting.TagAndLayerSizeValueType, 0); settings[(int)QHierarchySetting.TagAndLayerSizeValuePercent] = getEditorSetting(QHierarchySetting.TagAndLayerSizeValuePercent, 0.25f); string iconOrder = getEditorSetting(QHierarchySetting.IconOrder, DEFAULT_ORDER); if (iconOrder.Length != DEFAULT_ORDER.Length) { iconOrder = DEFAULT_ORDER; } List <QHierarchyIconType> iconOrderList = new List <QHierarchyIconType>(); int type; for (int i = 0; i < iconOrder.Length; i++) { if (int.TryParse(iconOrder[i].ToString(), out type)) { iconOrderList.Add((QHierarchyIconType)type); } else { iconOrderList.Clear(); QHierarchySettings.setSetting(QHierarchySetting.IconOrder, DEFAULT_ORDER); iconOrder = DEFAULT_ORDER; i = -1; } } settings[(int)QHierarchySetting.IconOrder] = iconOrderList; settings[(int)QHierarchySetting.Identation] = getEditorSetting(QHierarchySetting.Identation, 0); settings[(int)QHierarchySetting.ShowCustomTagIcon] = getEditorSetting(QHierarchySetting.ShowCustomTagIcon, true); List <QTagTexture> tagTextureList = new List <QTagTexture>(); string customTagIcon = getEditorSetting(QHierarchySetting.CustomTagIcon, ""); string[] customTagIconArray = customTagIcon.Split(new char[] { ';' }); List <string> tags = new List <string>(UnityEditorInternal.InternalEditorUtility.tags); for (int i = 0; i < customTagIconArray.Length - 1; i += 2) { string tag = customTagIconArray[i]; if (!tags.Contains(tag)) { continue; } string texturePath = customTagIconArray[i + 1]; Texture2D texture = (Texture2D)AssetDatabase.LoadAssetAtPath(texturePath, typeof(Texture2D)); if (texture != null) { QTagTexture tagTexture = new QTagTexture(tag, texture); tagTextureList.Add(tagTexture); } } settings[(int)QHierarchySetting.CustomTagIcon] = tagTextureList; settings[(int)QHierarchySetting.GeneralSettingsFoldout] = getEditorSetting(QHierarchySetting.GeneralSettingsFoldout, true); settings[(int)QHierarchySetting.AppearanceSettingsFoldout] = getEditorSetting(QHierarchySetting.AppearanceSettingsFoldout, true); settings[(int)QHierarchySetting.OrderSettingsFoldout] = getEditorSetting(QHierarchySetting.OrderSettingsFoldout, true); settings[(int)QHierarchySetting.ErrorIconSettingsFoldout] = getEditorSetting(QHierarchySetting.ErrorIconSettingsFoldout, true); settings[(int)QHierarchySetting.TagAndLayerSettingsFoldout] = getEditorSetting(QHierarchySetting.TagAndLayerSettingsFoldout, true); settings[(int)QHierarchySetting.CustomTagIconFoldout] = getEditorSetting(QHierarchySetting.CustomTagIconFoldout, true); settings[(int)QHierarchySetting.PreventSelectionOfLockedObjects] = getEditorSetting(QHierarchySetting.PreventSelectionOfLockedObjects, false); settings[(int)QHierarchySetting.LockSettingsFoldout] = getEditorSetting(QHierarchySetting.LockSettingsFoldout, true); settings[(int)QHierarchySetting.ShowStaticIcon] = getEditorSetting(QHierarchySetting.ShowStaticIcon, true); settings[(int)QHierarchySetting.CustomTagIconReplace] = getEditorSetting(QHierarchySetting.CustomTagIconReplace, true); settings[(int)QHierarchySetting.CustomTagIconTextureListFoldout] = getEditorSetting(QHierarchySetting.CustomTagIconTextureListFoldout, false); settings[(int)QHierarchySetting.ShowHiddenQHierarchyObjectList] = getEditorSetting(QHierarchySetting.ShowHiddenQHierarchyObjectList, true); settings[(int)QHierarchySetting.ShowModifierWarning] = getEditorSetting(QHierarchySetting.ShowModifierWarning, true); settings[(int)QHierarchySetting.ShowErrorForDisabledComponents] = getEditorSetting(QHierarchySetting.ShowErrorForDisabledComponents, true); settings[(int)QHierarchySetting.IgnoreUnityMonobehaviour] = getEditorSetting(QHierarchySetting.IgnoreUnityMonobehaviour, true); settings[(int)QHierarchySetting.MonoBehaviourIconFoldout] = getEditorSetting(QHierarchySetting.MonoBehaviourIconFoldout, true); settings[(int)QHierarchySetting.ShowMeshButton] = getEditorSetting(QHierarchySetting.ShowMeshButton, true); }