コード例 #1
0
ファイル: QHierarchy.cs プロジェクト: ludidilu/CSharpLib
        static float drawLockButton(GameObject gameObject, Rect rect)
        {
            rect.x    -= 13;
            rect.width = 13;

            bool isLock = objectList == null ? false : objectList.lockedObjects.Contains(gameObject);

            if (isLock == true && (gameObject.hideFlags & HideFlags.NotEditable) != HideFlags.NotEditable)
            {
                gameObject.hideFlags |= HideFlags.NotEditable;
                EditorUtility.SetDirty(gameObject);
            }
            else if (isLock == false && (gameObject.hideFlags & HideFlags.NotEditable) == HideFlags.NotEditable)
            {
                gameObject.hideFlags ^= HideFlags.NotEditable;
                EditorUtility.SetDirty(gameObject);
            }

            if (GUI.Button(rect, isLock ? QHierarchyResource.getTexture(QHierarchyTexture.ButtonLockOn) : QHierarchyResource.getTexture(QHierarchyTexture.ButtonLockOff), guiStyle))
            {
                Undo.RecordObject(getObjectList(), "Change GameObject Lock");

                bool showWarning = QHierarchySettings.getSetting <bool>(QHierarchySetting.ShowModifierWarning);
                if (Event.current.shift)
                {
                    if (!showWarning || EditorUtility.DisplayDialog("Change locking",
                                                                    "Are you sure you want to " + (isLock ? "unlock" : "lock") + " this GameObject and all its children?",
                                                                    "Yes",
                                                                    "Cancel"))
                    {
                        setLockRecursive(gameObject.transform, !isLock);
                    }
                }
                else if (Event.current.alt)
                {
                    if (!showWarning || EditorUtility.DisplayDialog("Change locking",
                                                                    "Are you sure you want to " + (isLock ? "unlock" : "lock") + " this GameObject and its siblings?",
                                                                    "Yes",
                                                                    "Cancel"))
                    {
                        setLockRecursive(gameObject.transform, !isLock, 1);
                    }
                }
                else
                {
                    setLockRecursive(gameObject.transform, !isLock, 0);
                }

                EditorUtility.SetDirty(objectList);
                if (Selection.activeGameObject != null)
                {
                    EditorUtility.SetDirty(Selection.activeGameObject);
                }
            }
            return(rect.width);
        }
コード例 #2
0
        static void drawTreeMap(GameObject gameObject, Rect selectionRect)
        {
            Transform gameObjectTransform = gameObject.transform;

            bool hasChild = false;

            hasChild = gameObjectTransform.childCount > 0;

            bool foundCustomComponent = false;

            if (QHierarchySettings.getSetting <bool>(QHierarchySetting.IgnoreUnityMonobehaviour))
            {
                Component[] components = gameObject.GetComponents <MonoBehaviour>();

                for (int i = 0; i < components.Length; i++)
                {
                    if (components[i] != null)
                    {
                        string fullName = components[i].GetType().FullName;
                        if (fullName.Contains("UnityEngine"))
                        {
                            continue;
                        }
                        foundCustomComponent = true;
                        break;
                    }
                }
            }
            else
            {
                foundCustomComponent = gameObject.GetComponent <MonoBehaviour>() != null;
            }

            Rect treeMapRect = new Rect(selectionRect);

            treeMapRect.width = treeMapRect.x + 28;
            treeMapRect.x     = 0;

            int ident = Mathf.FloorToInt(treeMapRect.width / 14) - 1;

            treeMapRect.width = (ident) * 14;
            float stepX  = 1.0f / (896.0f / 14.0f);
            float rectX  = (hasChild ? 1.0f : 0.5f) - ident * stepX;
            float scaleX = ident * stepX;

            bool showMonoBehaviourIcon = QHierarchySettings.getSetting <bool>(QHierarchySetting.ShowMonoBehaviourIcon);

            float stepY = 1.0f / (64.0f / 16.0f);
            float rectY = 1.0f - stepY * (QHierarchySettings.getSetting <bool>(QHierarchySetting.ShowTreeMap) ?
                                          (showMonoBehaviourIcon ? (foundCustomComponent == false ? 1 : 2) : 1) :
                                          (showMonoBehaviourIcon ? (foundCustomComponent == false ? 3 : 4) : 3));
            float scaleY = 0.25f;

            GUI.DrawTextureWithTexCoords(treeMapRect, QHierarchyResource.getTexture(QHierarchyTexture.BackgroundTreeMap), new Rect(rectX, rectY, scaleX, scaleY));
        }
コード例 #3
0
ファイル: QHierarchy.cs プロジェクト: ludidilu/CSharpLib
        static float drawStaticIcon(GameObject gameObject, Rect rect)
        {
            rect.x    -= 14;
            rect.width = 14;

            bool isStatic = gameObject.isStatic;
            StaticEditorFlags staticFlags = GameObjectUtility.GetStaticEditorFlags(gameObject);

            Texture2D buttonTexture = isStatic ?
                                      ((int)staticFlags == -1 ?
                                       QHierarchyResource.getTexture(QHierarchyTexture.ButtonStaticOn)
                    : QHierarchyResource.getTexture(QHierarchyTexture.ButtonStaticHalf))
                : QHierarchyResource.getTexture(QHierarchyTexture.ButtonStaticOff);

            if (GUI.Button(rect, buttonTexture, guiStyle))
            {
                Undo.RecordObject(gameObject, "Change GameObject Static");

                bool showWarning = QHierarchySettings.getSetting <bool>(QHierarchySetting.ShowModifierWarning);
                if (Event.current.shift)
                {
                    if (!showWarning || EditorUtility.DisplayDialog("Change static",
                                                                    "Are you sure you want to " + (isStatic ? "disable" : "enable") + " Static of this GameObject and all its children?",
                                                                    "Yes",
                                                                    "Cancel"))
                    {
                        setStaticRecursive(gameObject.transform, !isStatic);
                    }
                }
                else if (Event.current.alt)
                {
                    if (!showWarning || EditorUtility.DisplayDialog("Change static",
                                                                    "Are you sure you want to " + (isStatic ? "disable" : "enable") + " Static of this GameObject and all its siblings?",
                                                                    "Yes",
                                                                    "Cancel"))
                    {
                        setStaticRecursive(gameObject.transform, !isStatic, 1);
                    }
                }
                else
                {
                    setStaticRecursive(gameObject.transform, !isStatic, 0);
                }
            }
            return(rect.width);
        }
コード例 #4
0
        static float drawErrorIcon(GameObject gameObject, Rect rect)
        {
            bool fixedIconWidth = QHierarchySettings.getSetting <bool>(QHierarchySetting.FixedIconWidth);
            bool errorFound     = findError(gameObject.GetComponents <MonoBehaviour>());

            if (errorFound)
            {
                rect.x    -= 16;
                rect.width = 16;
                EditorGUI.DrawRect(rect, backgroundColor);
                GUI.DrawTexture(rect, QHierarchyResource.getTexture(QHierarchyTexture.IconError));
            }
            else if (fixedIconWidth)
            {
                rect.x    -= 16;
                rect.width = 16;
                EditorGUI.DrawRect(rect, backgroundColor);
                rect.x += 16;
            }

            if (QHierarchySettings.getSetting <bool>(QHierarchySetting.ShowErrorIconParent) && !errorFound)
            {
                bool childErrorFound = findError(gameObject.GetComponentsInChildren <MonoBehaviour>(true));
                if (childErrorFound)
                {
                    rect.x    -= 16;
                    rect.width = 16;
                    GUI.DrawTexture(rect, QHierarchyResource.getTexture(QHierarchyTexture.IconErrorChild));
                }
                return(childErrorFound ? 16 : (fixedIconWidth ? 16 : 0));
            }
            else
            {
                return(errorFound ? 16 : (fixedIconWidth ? 16 : 0));
            }
        }
コード例 #5
0
        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();
        }
コード例 #6
0
        static float drawStaticIcon(GameObject gameObject, Rect rect)
        {
            rect.x    -= 14;
            rect.width = 14;

            bool isStatic = gameObject.isStatic;
            StaticEditorFlags staticFlags = GameObjectUtility.GetStaticEditorFlags(gameObject);

            Texture2D buttonTexture = isStatic ?
                                      ((int)staticFlags == -1 ?
                                       QHierarchyResource.getTexture(QHierarchyTexture.ButtonStaticOn)
                    : QHierarchyResource.getTexture(QHierarchyTexture.ButtonStaticHalf))
                : QHierarchyResource.getTexture(QHierarchyTexture.ButtonStaticOff);

            GUI.DrawTexture(rect, buttonTexture);

            if (Event.current.isMouse && Event.current.button == 0 && rect.Contains(Event.current.mousePosition))
            {
                if (Event.current.type == EventType.MouseDown)
                {
                    targetStaticState = ((!isStatic) == true ? 1 : 0);
                }
                else if (Event.current.type == EventType.MouseDrag && targetStaticState != -1)
                {
                    if (targetStaticState == (isStatic == true ? 1 : 0))
                    {
                        return(rect.width);
                    }
                }
                else
                {
                    targetStaticState = -1;
                    return(rect.width);
                }

                Event.current.Use();

                Undo.RecordObject(gameObject, "Change GameObject Static");

                bool showWarning = QHierarchySettings.getSetting <bool>(QHierarchySetting.ShowModifierWarning);
                if (Event.current.shift)
                {
                    if (!showWarning || EditorUtility.DisplayDialog("Change static",
                                                                    "Are you sure you want to " + (isStatic ? "disable" : "enable") + " Static of this GameObject and all its children? (You can disable this warning in the settings)",
                                                                    "Yes",
                                                                    "Cancel"))
                    {
                        setStaticRecursive(gameObject.transform, !isStatic);
                    }
                }
                else if (Event.current.alt)
                {
                    if (!showWarning || EditorUtility.DisplayDialog("Change static",
                                                                    "Are you sure you want to " + (isStatic ? "disable" : "enable") + " Static of this GameObject and all its siblings? (You can disable this warning in the settings)",
                                                                    "Yes",
                                                                    "Cancel"))
                    {
                        setStaticRecursive(gameObject.transform, !isStatic, 1);
                    }
                }
                else
                {
                    setStaticRecursive(gameObject.transform, !isStatic, 0);
                }
            }
            return(rect.width);
        }
コード例 #7
0
        static float drawMeshButton(GameObject gameObject, Rect rect)
        {
            Renderer renderer = gameObject.GetComponent <Renderer>();

            if (renderer != null)
            {
                bool wireframeHiddenObjectsContains = objectList == null ? false : objectList.wireframeHiddenObjects.Contains(gameObject);

                rect.x    -= 14;
                rect.width = 14;
                GUI.DrawTexture(rect, wireframeHiddenObjectsContains ? QHierarchyResource.getTexture(QHierarchyTexture.ButtonMeshWireframe) :
                                (renderer.enabled ?
                                 QHierarchyResource.getTexture(QHierarchyTexture.ButtonMeshOn) :
                                 QHierarchyResource.getTexture(QHierarchyTexture.ButtonMeshOff)));

                if (Event.current.isMouse && Event.current.button == 0 && rect.Contains(Event.current.mousePosition))
                {
                    bool isEnabled = renderer.enabled;

                    if (Event.current.type == EventType.MouseDown)
                    {
                        targetMeshState = ((!isEnabled) == true ? 1 : 0);
                    }
                    else if (Event.current.type == EventType.MouseDrag && targetMeshState != -1)
                    {
                        if (targetMeshState == (isEnabled == true ? 1 : 0))
                        {
                            return(rect.width);
                        }
                    }
                    else
                    {
                        targetMeshState = -1;
                        return(rect.width);
                    }

                    Event.current.Use();

                    Undo.RecordObject(renderer, "Change GameObject Mesh Enable");

                    if (Event.current.control || Event.current.command)
                    {
                        if (!wireframeHiddenObjectsContains)
                        {
                            EditorUtility.SetSelectedWireframeHidden(renderer, true);
                            objectList.wireframeHiddenObjects.Add(gameObject);
                            SceneView.RepaintAll();
                        }
                    }
                    else
                    {
                        if (wireframeHiddenObjectsContains)
                        {
                            EditorUtility.SetSelectedWireframeHidden(renderer, false);
                            objectList.wireframeHiddenObjects.Remove(gameObject);
                            SceneView.RepaintAll();
                        }
                        else
                        {
                            renderer.enabled = !isEnabled;
                        }
                    }
                }
                return(rect.width);
            }
            else
            {
                bool fixedIconWidth = QHierarchySettings.getSetting <bool>(QHierarchySetting.FixedIconWidth);
                if (fixedIconWidth)
                {
                    rect.x    -= 14;
                    rect.width = 14;
                    EditorGUI.DrawRect(rect, backgroundColor);
                    return(rect.width);
                }
            }
            return(0);
        }
コード例 #8
0
        static float drawLockButton(GameObject gameObject, Rect rect)
        {
            rect.x    -= 13;
            rect.width = 13;

            bool isLock = objectList == null ? false : objectList.lockedObjects.Contains(gameObject);

            if (isLock == true && (gameObject.hideFlags & HideFlags.NotEditable) != HideFlags.NotEditable)
            {
                gameObject.hideFlags |= HideFlags.NotEditable;
                EditorUtility.SetDirty(gameObject);
            }
            else if (isLock == false && (gameObject.hideFlags & HideFlags.NotEditable) == HideFlags.NotEditable)
            {
                gameObject.hideFlags ^= HideFlags.NotEditable;
                EditorUtility.SetDirty(gameObject);
            }

            GUI.DrawTexture(rect, isLock ? QHierarchyResource.getTexture(QHierarchyTexture.ButtonLockOn) : QHierarchyResource.getTexture(QHierarchyTexture.ButtonLockOff));

            if (Event.current.isMouse && Event.current.button == 0 && rect.Contains(Event.current.mousePosition))
            {
                if (Event.current.type == EventType.MouseDown)
                {
                    targetLockState = ((!isLock) == true ? 1 : 0);
                }
                else if (Event.current.type == EventType.MouseDrag && targetLockState != -1)
                {
                    if (targetLockState == (isLock == true ? 1 : 0))
                    {
                        return(rect.width);
                    }
                }
                else
                {
                    targetLockState = -1;
                    return(rect.width);
                }

                Event.current.Use();

                Undo.RecordObject(getObjectList(), "Change GameObject Lock");

                bool showWarning = QHierarchySettings.getSetting <bool>(QHierarchySetting.ShowModifierWarning);
                if (Event.current.shift)
                {
                    if (!showWarning || EditorUtility.DisplayDialog("Change locking",
                                                                    "Are you sure you want to " + (isLock ? "unlock" : "lock") + " this GameObject and all its children? (You can disable this warning in the settings)",
                                                                    "Yes",
                                                                    "Cancel"))
                    {
                        setLockRecursive(gameObject.transform, !isLock);
                    }
                }
                else if (Event.current.alt)
                {
                    if (!showWarning || EditorUtility.DisplayDialog("Change locking",
                                                                    "Are you sure you want to " + (isLock ? "unlock" : "lock") + " this GameObject and its siblings? (You can disable this warning in the settings)",
                                                                    "Yes",
                                                                    "Cancel"))
                    {
                        setLockRecursive(gameObject.transform, !isLock, 1);
                    }
                }
                else
                {
                    setLockRecursive(gameObject.transform, !isLock, 0);
                }

                EditorUtility.SetDirty(objectList);
                if (Selection.activeGameObject != null)
                {
                    EditorUtility.SetDirty(Selection.activeGameObject);
                }
            }
            return(rect.width);
        }
コード例 #9
0
        static float drawVisibilityButton(GameObject gameObject, Rect rect)
        {
            rect.x    -= 18;
            rect.width = 18;

            int visibility = gameObject.activeSelf ? 1 : 0;

            bool editModeVisibleObjectsContains   = objectList == null ? false : objectList.editModeVisibileObjects.Contains(gameObject);
            bool editModeInvisibleObjectsContains = objectList == null ? false : objectList.editModeInvisibleObjects.Contains(gameObject);

            if (!EditorApplication.isPlayingOrWillChangePlaymode &&
                ((!gameObject.activeSelf && editModeVisibleObjectsContains) ||
                 (gameObject.activeSelf && editModeInvisibleObjectsContains)))
            {
                gameObject.SetActive(!gameObject.activeSelf);
            }

            if (visibility == 1)
            {
                Transform transform = gameObject.transform;
                while (transform.parent != null)
                {
                    transform = transform.parent;
                    if (!transform.gameObject.activeSelf)
                    {
                        visibility = 2;
                        break;
                    }
                }
            }

            Texture2D visibilityIcon;

            if (!EditorApplication.isPlayingOrWillChangePlaymode && (editModeVisibleObjectsContains || editModeInvisibleObjectsContains))
            {
                visibilityIcon = visibility == 0 ? QHierarchyResource.getTexture(QHierarchyTexture.ButtonVisibilityOffEdit) : visibility == 1 ? QHierarchyResource.getTexture(QHierarchyTexture.ButtonVisibilityOnEdit) : QHierarchyResource.getTexture(QHierarchyTexture.ButtonVisibilityOffParentEdit);
            }
            else
            {
                visibilityIcon = visibility == 0 ? QHierarchyResource.getTexture(QHierarchyTexture.ButtonVisibilityOff) : visibility == 1 ? QHierarchyResource.getTexture(QHierarchyTexture.ButtonVisibilityOn) : QHierarchyResource.getTexture(QHierarchyTexture.ButtonVisibilityOffParent);
            }

            GUI.DrawTexture(rect, visibilityIcon);

            if (Event.current.isMouse && Event.current.button == 0 && rect.Contains(Event.current.mousePosition))
            {
                if (Event.current.type == EventType.MouseDown)
                {
                    targetVisibilityState = ((!gameObject.activeSelf) == true ? 1 : 0);
                }
                else if (Event.current.type == EventType.MouseDrag && targetVisibilityState != -1)
                {
                    if (targetVisibilityState == (gameObject.activeSelf == true ? 1 : 0))
                    {
                        return(rect.width);
                    }
                }
                else
                {
                    targetVisibilityState = -1;
                    return(rect.width);
                }

                Event.current.Use();

                Undo.RecordObject(gameObject, "Change GameObject Visibility");

                bool showWarning = QHierarchySettings.getSetting <bool>(QHierarchySetting.ShowModifierWarning);
                if (Event.current.control || Event.current.command)
                {
                    if (Event.current.shift)
                    {
                        if (!showWarning || EditorUtility.DisplayDialog("Change edit-time visibility",
                                                                        "Are you sure you want to turn " + (gameObject.activeSelf ? "off" : "on") + " the edit-time visibility of this GameObject and all its children? (You can disable this warning in the settings)",
                                                                        "Yes",
                                                                        "Cancel"))
                        {
                            setEditModeVisibilityRecursive(gameObject, !gameObject.activeSelf);
                        }
                    }
                    else if (Event.current.alt)
                    {
                        if (!showWarning || EditorUtility.DisplayDialog("Change edit-time visibility",
                                                                        "Are you sure you want to turn " + (gameObject.activeSelf ? "off" : "on") + " the edit-time visibility this GameObject and its siblings? (You can disable this warning in the settings)",
                                                                        "Yes",
                                                                        "Cancel"))
                        {
                            setEditModeVisibilityRecursive(gameObject, !gameObject.activeSelf, 1);
                        }
                    }
                    else
                    {
                        setEditModeVisibilityRecursive(gameObject, !gameObject.activeSelf, 0);
                    }
                }
                else if (Event.current.shift)
                {
                    if (!showWarning || EditorUtility.DisplayDialog("Change visibility",
                                                                    "Are you sure you want to turn " + (gameObject.activeSelf ? "off" : "on") + " the visibility of this GameObject and all its children? (You can disable this warning in the settings)",
                                                                    "Yes",
                                                                    "Cancel"))
                    {
                        setVisibilityRecursive(gameObject.transform, !gameObject.activeSelf);
                    }
                }
                else if (Event.current.alt)
                {
                    if (!showWarning || EditorUtility.DisplayDialog("Change visibility",
                                                                    "Are you sure you want to turn " + (gameObject.activeSelf ? "off" : "on") + " the visibility this GameObject and its siblings? (You can disable this warning in the settings)",
                                                                    "Yes",
                                                                    "Cancel"))
                    {
                        setVisibilityRecursive(gameObject.transform, !gameObject.activeSelf, 1);
                    }
                }
                else
                {
                    setVisibilityRecursive(gameObject.transform, !gameObject.activeSelf, 0);
                }
            }

            return(rect.width);
        }
コード例 #10
0
ファイル: QHierarchy.cs プロジェクト: ludidilu/CSharpLib
        static float drawVisibilityButton(GameObject gameObject, Rect rect)
        {
            rect.x    -= 18;
            rect.width = 18;

            int visibility = gameObject.activeSelf ? 1 : 0;

            bool editModeVisibleObjectsContains   = objectList == null ? false : objectList.editModeVisibileObjects.Contains(gameObject);
            bool editModeInvisibleObjectsContains = objectList == null ? false : objectList.editModeInvisibleObjects.Contains(gameObject);

            if (!EditorApplication.isPlayingOrWillChangePlaymode &&
                ((!gameObject.activeSelf && editModeVisibleObjectsContains) ||
                 (gameObject.activeSelf && editModeInvisibleObjectsContains)))
            {
                gameObject.SetActive(!gameObject.activeSelf);
            }

            if (visibility == 1)
            {
                Transform transform = gameObject.transform;
                while (transform.parent != null)
                {
                    transform = transform.parent;
                    if (!transform.gameObject.activeSelf)
                    {
                        visibility = 2;
                        break;
                    }
                }
            }

            Texture2D visibilityIcon;

            if (!EditorApplication.isPlayingOrWillChangePlaymode && (editModeVisibleObjectsContains || editModeInvisibleObjectsContains))
            {
                visibilityIcon = visibility == 0 ? QHierarchyResource.getTexture(QHierarchyTexture.ButtonVisibilityOffEdit) : visibility == 1 ? QHierarchyResource.getTexture(QHierarchyTexture.ButtonVisibilityOnEdit) : QHierarchyResource.getTexture(QHierarchyTexture.ButtonVisibilityOffParentEdit);
            }
            else
            {
                visibilityIcon = visibility == 0 ? QHierarchyResource.getTexture(QHierarchyTexture.ButtonVisibilityOff) : visibility == 1 ? QHierarchyResource.getTexture(QHierarchyTexture.ButtonVisibilityOn) : QHierarchyResource.getTexture(QHierarchyTexture.ButtonVisibilityOffParent);
            }

            if (GUI.Button(rect, visibilityIcon, guiStyle))
            {
                Undo.RecordObject(gameObject, "Change GameObject Visibility");

                if (Event.current.control || Event.current.command)
                {
                    if (gameObject.activeSelf)
                    {
                        if (editModeVisibleObjectsContains)
                        {
                            objectList.editModeVisibileObjects.Remove(gameObject);
                        }

                        getObjectList().editModeInvisibleObjects.Add(gameObject);
                    }
                    else
                    {
                        if (editModeInvisibleObjectsContains)
                        {
                            objectList.editModeInvisibleObjects.Remove(gameObject);
                        }

                        getObjectList().editModeVisibileObjects.Add(gameObject);
                    }
                }
                else
                {
                    if (editModeVisibleObjectsContains)
                    {
                        objectList.editModeVisibileObjects.Remove(gameObject);
                    }

                    if (editModeInvisibleObjectsContains)
                    {
                        objectList.editModeInvisibleObjects.Remove(gameObject);
                    }
                }

                bool showWarning = QHierarchySettings.getSetting <bool>(QHierarchySetting.ShowModifierWarning);
                if (Event.current.shift)
                {
                    if (!showWarning || EditorUtility.DisplayDialog("Change visibility",
                                                                    "Are you sure you want to turn " + (gameObject.activeSelf ? "off" : "on") + " the visibility of this GameObject and all its children?",
                                                                    "Yes",
                                                                    "Cancel"))
                    {
                        setVisibilityRecursive(gameObject.transform, !gameObject.activeSelf);
                    }
                }
                else if (Event.current.alt)
                {
                    if (!showWarning || EditorUtility.DisplayDialog("Change visibility",
                                                                    "Are you sure you want to turn " + (gameObject.activeSelf ? "off" : "on") + " the visibility this GameObject and its siblings?",
                                                                    "Yes",
                                                                    "Cancel"))
                    {
                        setVisibilityRecursive(gameObject.transform, !gameObject.activeSelf, 1);
                    }
                }
                else if (Event.current.control || Event.current.command)
                {
                    gameObject.SetActive(!gameObject.activeSelf);
                }
                else
                {
                    setVisibilityRecursive(gameObject.transform, !gameObject.activeSelf, 0);
                }
            }

            return(rect.width);
        }
コード例 #11
0
ファイル: QHierarchy.cs プロジェクト: lixing1993122/ResetCore
        static float drawLockButton(QObjectList objectList, GameObject gameObject, Rect rect)
        {
            rect.x    -= 13;
            rect.width = 13;

            bool isLock = objectList == null ? false : objectList.lockedObjects.Contains(gameObject);

            if (isLock == true && (gameObject.hideFlags & HideFlags.NotEditable) != HideFlags.NotEditable)
            {
                gameObject.hideFlags |= HideFlags.NotEditable;
                EditorUtility.SetDirty(gameObject);
            }
            else if (isLock == false && (gameObject.hideFlags & HideFlags.NotEditable) == HideFlags.NotEditable)
            {
                gameObject.hideFlags ^= HideFlags.NotEditable;
                EditorUtility.SetDirty(gameObject);
            }

            GUI.DrawTexture(rect, isLock ? QHierarchyResource.getTexture(QHierarchyTexture.ButtonLockOn) : QHierarchyResource.getTexture(QHierarchyTexture.ButtonLockOff));

            if (Event.current.isMouse && Event.current.button == 0 && rect.Contains(Event.current.mousePosition))
            {
                if (Event.current.type == EventType.MouseDown)
                {
                    targetLockState = ((!isLock) == true ? 1 : 0);
                }
                else if (Event.current.type == EventType.MouseDrag && targetLockState != -1)
                {
                    if (targetLockState == (isLock == true ? 1 : 0))
                    {
                        return(rect.width);
                    }
                }
                else
                {
                    targetLockState = -1;
                    return(rect.width);
                }

                if (objectList == null)
                {
                    objectList = createObjectListInScene(gameObject.scene);
                }

                Event.current.Use();
                bool showWarning = QHierarchySettings.getSetting <bool>(QHierarchySetting.ShowModifierWarning);

                List <GameObject> targetGameObjects = new List <GameObject>();
                if (Event.current.shift)
                {
                    if (!showWarning || EditorUtility.DisplayDialog("Change locking", "Are you sure you want to " + (isLock ? "unlock" : "lock") + " this GameObject and all its children? (You can disable this warning in the settings)", "Yes", "Cancel"))
                    {
                        getGameObjectListRecursive(ref targetGameObjects, gameObject);
                    }
                }
                else if (Event.current.alt)
                {
                    if (gameObject.transform.parent != null)
                    {
                        if (!showWarning || EditorUtility.DisplayDialog("Change locking", "Are you sure you want to " + (isLock ? "unlock" : "lock") + " this GameObject and its siblings? (You can disable this warning in the settings)", "Yes", "Cancel"))
                        {
                            getGameObjectListRecursive(ref targetGameObjects, gameObject.transform.parent.gameObject, 1);
                            targetGameObjects.Remove(gameObject.transform.parent.gameObject);
                        }
                    }
                    else
                    {
                        gameObject.scene.GetRootGameObjects(targetGameObjects);;
                    }
                }
                else
                {
                    if (Selection.Contains(gameObject))
                    {
                        targetGameObjects.AddRange(Selection.gameObjects);
                    }
                    else
                    {
                        getGameObjectListRecursive(ref targetGameObjects, gameObject, 0);
                    };
                }

                setLock(objectList, targetGameObjects, !isLock);
            }
            return(rect.width);
        }