示例#1
0
        // PRIVATE
        private void settingsChanged()
        {
            enabled = QSettings.getInstance().get <bool>(QSetting.LayerIconShow);
            showComponentDuringPlayMode = QSettings.getInstance().get <bool>(QSetting.LayerIconShowDuringPlayMode);
            QHierarchySizeAll size = (QHierarchySizeAll)QSettings.getInstance().get <int>(QSetting.LayerIconSize);

            rect.width            = rect.height = (size == QHierarchySizeAll.Normal ? 15 : (size == QHierarchySizeAll.Big ? 16 : 13));
            this.layerTextureList = QLayerTexture.loadLayerTextureList();
        }
示例#2
0
        public override void draw(GameObject gameObject, QObjectList objectList, Rect selectionRect)
        {
            string gameObjectLayerName = LayerMask.LayerToName(gameObject.layer);

            QLayerTexture layerTexture = layerTextureList.Find(t => t.layer == gameObjectLayerName);

            if (layerTexture != null && layerTexture.texture != null)
            {
                GUI.DrawTexture(rect, layerTexture.texture, ScaleMode.ScaleToFit, true);
            }
        }
        private void drawLayerIconComponentSettings()
        {
            if (drawComponentCheckBox("Layer Icon", QSetting.LayerIconShow))
            {
                string[] layers = UnityEditorInternal.InternalEditorUtility.layers;

                bool showLayerIconList = QSettings.getInstance().get <bool>(QSetting.LayerIconListFoldout);

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

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

                drawSpace(4);
                drawCheckBoxRight("Show component during play mode", QSetting.LayerIconShowDuringPlayMode);
                drawEnum("Icon size", QSetting.LayerIconSize, typeof(QHierarchySizeAll));
                drawSpace(4);
                if (drawFoldout("Layer icon list", QSetting.LayerIconListFoldout))
                {
                    List <QLayerTexture> layerTextureList = QLayerTexture.loadLayerTextureList();

                    bool changed = false;
                    for (int i = 0; i < layers.Length; i++)
                    {
                        string        layer        = layers[i];
                        QLayerTexture layerTexture = layerTextureList.Find(t => t.layer == layer);
                        Texture2D     newTexture   = (Texture2D)EditorGUI.ObjectField(getControlRect(0, 16, 31, 6),
                                                                                      layer, layerTexture == null ? null : layerTexture.texture, typeof(Texture2D), false);
                        if (newTexture != null && layerTexture == null)
                        {
                            QLayerTexture newLayerTexture = new QLayerTexture(layer, newTexture);
                            layerTextureList.Add(newLayerTexture);

                            changed = true;
                        }
                        else if (newTexture == null && layerTexture != null)
                        {
                            layerTextureList.Remove(layerTexture);
                            changed = true;
                        }
                        else if (layerTexture != null && layerTexture.texture != newTexture)
                        {
                            layerTexture.texture = newTexture;
                            changed = true;
                        }

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

                    if (changed)
                    {
                        QLayerTexture.saveLayerTextureList(QSetting.LayerIconList, layerTextureList);
                        EditorApplication.RepaintHierarchyWindow();
                    }
                }

                drawSpace(1);
            }
        }