Exemple #1
0
        // PRIVATE
        private void settingsChanged()
        {
            enabled = QSettings.getInstance().get <bool>(QSetting.TagIconShow);
            showComponentDuringPlayMode = QSettings.getInstance().get <bool>(QSetting.TagIconShowDuringPlayMode);
            QHierarchySizeAll size = (QHierarchySizeAll)QSettings.getInstance().get <int>(QSetting.TagIconSize);

            rect.width          = rect.height = (size == QHierarchySizeAll.Normal ? 15 : (size == QHierarchySizeAll.Big ? 16 : 13));
            this.tagTextureList = QTagTexture.loadTagTextureList();
        }
        private void drawTagIconComponentSettings()
        {
            if (drawComponentCheckBox(QSetting.ShowTagIconComponent, "Tag Icon"))
            {
                bool changed = false;
                List <QTagTexture> tagTextureList = QSettings.getInstance().get <List <QTagTexture> >(QSetting.CustomTagIcon);
                string[]           tags           = UnityEditorInternal.InternalEditorUtility.tags;

                Rect rect = getControlRect(0, 18);
                drawBackground(rect.x, rect.y, rect.width, 18 + 18 * tags.Length + 5);
                rect.x     += 31;
                rect.width -= 31 + 6;

                drawCheckBoxRight(rect, QSetting.ShowTagIconComponentDuringPlayMode, "Show Component During Play Mode");

                drawSpace(4);

                for (int i = 0; i < tags.Length; i++)
                {
                    string      tag        = tags[i];
                    QTagTexture tagTexture = tagTextureList.Find(t => t.tag == tag);
                    Texture2D   newTexture = (Texture2D)EditorGUI.ObjectField(getControlRect(0, 16, 31, 6),
                                                                              tag, tagTexture == null ? null : tagTexture.texture, typeof(Texture2D), false);
                    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;
                    }

                    drawSpace(i == tags.Length - 1 ? 2 : 2);
                }

                if (changed)
                {
                    QSettings.getInstance().set(QSetting.CustomTagIcon, tagTextureList);
                    EditorApplication.RepaintHierarchyWindow();
                }
            }
        }
Exemple #3
0
        public override void draw(GameObject gameObject, QObjectList objectList, Rect selectionRect)
        {
            string gameObjectTag = "";

            try { gameObjectTag = gameObject.tag; }
            catch {}

            QTagTexture tagTexture = tagTextureList.Find(t => t.tag == gameObjectTag);

            if (tagTexture != null && tagTexture.texture != null)
            {
                GUI.DrawTexture(rect, tagTexture.texture, ScaleMode.ScaleToFit, true);
            }
        }
Exemple #4
0
        public override void draw(GameObject gameObject, QObjectList objectList, Rect selectionRect, Rect curRect)
        {
            string gameObjectTag = "";

            try { gameObjectTag = gameObject.tag; }
            catch {}

            QTagTexture tagTexture = QSettings.getInstance().get <List <QTagTexture> >(QSetting.CustomTagIcon).Find(t => t.tag == gameObjectTag);

            EditorGUI.DrawRect(curRect, backgroundColor);
            if (tagTexture != null && tagTexture.texture != null)
            {
                curRect.width = 16;
                GUI.DrawTexture(curRect, tagTexture.texture, ScaleMode.ScaleToFit, true);
            }
        }
        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();
            }
        }
        private void drawTagIconComponentSettings()
        {
            if (drawComponentCheckBox("Tag Icon", QSetting.TagIconShow))
            {
                string[] tags = UnityEditorInternal.InternalEditorUtility.tags;

                bool showTagIconList = QSettings.getInstance().get <bool>(QSetting.TagIconListFoldout);

                Rect rect = getControlRect(0, 0);
                if (drawRestore())
                {
                    QSettings.getInstance().restore(QSetting.TagIconShowDuringPlayMode);
                    QSettings.getInstance().restore(QSetting.TagIconSize);
                }

                drawBackground(rect.x, rect.y, rect.width, 18 * 3 + (showTagIconList ? 18 * tags.Length : 0) + 4 + 5);

                drawSpace(4);
                drawCheckBoxRight("Show component during play mode", QSetting.TagIconShowDuringPlayMode);
                drawEnum("Icon size", QSetting.TagIconSize, typeof(QHierarchySizeAll));
                drawSpace(4);
                if (drawFoldout("Tag icon list", QSetting.TagIconListFoldout))
                {
                    List <QTagTexture> tagTextureList = QTagTexture.loadTagTextureList();

                    bool changed = false;
                    for (int i = 0; i < tags.Length; i++)
                    {
                        string      tag        = tags[i];
                        QTagTexture tagTexture = tagTextureList.Find(t => t.tag == tag);
                        Texture2D   newTexture = (Texture2D)EditorGUI.ObjectField(getControlRect(0, 16, 31, 6),
                                                                                  tag, tagTexture == null ? null : tagTexture.texture, typeof(Texture2D), false);
                        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;
                        }

                        drawSpace(i == tags.Length - 1 ? 2 : 2);
                    }

                    if (changed)
                    {
                        QTagTexture.saveTagTextureList(QSetting.TagIconList, tagTextureList);
                        EditorApplication.RepaintHierarchyWindow();
                    }
                }

                drawSpace(1);
            }
        }