示例#1
0
        static void setLock(QObjectList objectList, List <GameObject> gameObjects, bool targetLock)
        {
            Undo.RecordObject(objectList, targetLock ? "lock" : "unlock");

            for (int i = gameObjects.Count - 1; i >= 0; i--)
            {
                GameObject curGameObject = gameObjects[i];
                Undo.RecordObject(curGameObject, targetLock ? "lock" : "unlock");

                if (targetLock)
                {
                    curGameObject.hideFlags |= HideFlags.NotEditable;
                    if (!objectList.lockedObjects.Contains(curGameObject))
                    {
                        objectList.lockedObjects.Add(curGameObject);
                    }
                }
                else
                {
                    curGameObject.hideFlags &= ~HideFlags.NotEditable;
                    objectList.lockedObjects.Remove(curGameObject);
                }

                EditorUtility.SetDirty(curGameObject);
            }
        }
示例#2
0
        public static QObjectList getObjectList(bool createIfNotExist = true)
        {
            if (objectList == null)
            {
                QObjectList[] objectListArray = (QObjectList[])GameObject.FindObjectsOfType <QObjectList>();
                for (int i = 0; i < objectListArray.Length; i++)
                {
                    if (objectListArray[i].name == ObjectListName)
                    {
                        if (objectList == null)
                        {
                            objectList = objectListArray[i];
                        }
                        else
                        {
                            objectList.merge(objectListArray[i]);
                            GameObject.DestroyImmediate(objectListArray[i].gameObject);
                        }
                    }
                }

                if (objectList == null && createIfNotExist)
                {
                    GameObject gameObjectList = new GameObject();
                    gameObjectList.name = ObjectListName;
                    gameObjectList.tag  = "EditorOnly";
                    objectList          = gameObjectList.AddComponent <QObjectList>();
                }
            }
            return(objectList);
        }
示例#3
0
        static void Update()
        {
            if (!inited) init();
             
            if (objectList == null) 
            {
                objectList = getObjectList(false);
                if (objectList == null) return;
            }

            HideFlags hideFlag = QHierarchySettings.getSetting<bool>(QHierarchySetting.ShowHiddenQHierarchyObjectList) ? HideFlags.None : HideFlags.HideInHierarchy;

            #if !UNITY_4_6  
                hideFlag = hideFlag | HideFlags.DontSaveInBuild;     
            #endif

            if (objectList.gameObject.hideFlags != hideFlag)
                objectList.gameObject.hideFlags = hideFlag;                            
            
            if (QHierarchySettings.getSetting<bool>(QHierarchySetting.ShowLockButton) &&
                QHierarchySettings.getSetting<bool>(QHierarchySetting.PreventSelectionOfLockedObjects))
            {
                GameObject[] selections = Selection.gameObjects;
                List<GameObject> actual = new List<GameObject>();
                bool found = false;
                for (int i = 0; i < selections.Length; i++)
                {
                    bool isLock = objectList.lockedObjects.Contains(selections[i]);
                    if (!isLock) actual.Add(selections[i]);
                    else found = true;
                }
                if (found) Selection.objects = actual.ToArray();
            }
        }
示例#4
0
        public static void updateObjectListDictionary()
        {
            objectListDictionary.Clear();
            QObjectList[] objectListArray = (QObjectList[])GameObject.FindObjectsOfType <QObjectList>();
            for (int i = 0; i < objectListArray.Length; i++)
            {
                QObjectList curObjectList = objectListArray[i];
                if (curObjectList.name == ObjectListName && objectListDictionary.ContainsKey(curObjectList.gameObject.scene))
                {
                    objectListDictionary[curObjectList.gameObject.scene].merge(curObjectList);
                    GameObject.DestroyImmediate(curObjectList.gameObject);
                }
                else
                {
                    objectListDictionary.Add(curObjectList.gameObject.scene, curObjectList);
                }
            }

            foreach (KeyValuePair <Scene, QObjectList> objectListKeyValue in objectListDictionary)
            {
                QObjectList       objectList             = objectListKeyValue.Value;
                List <GameObject> wireframeHiddenObjects = objectList.wireframeHiddenObjects;
                foreach (GameObject gameObject in wireframeHiddenObjects)
                {
                    Renderer renderer = gameObject.GetComponent <Renderer>();
                    if (renderer != null)
                    {
                        EditorUtility.SetSelectedWireframeHidden(renderer, true);
                    }
                }
            }
            lastActiveScene = EditorSceneManager.GetActiveScene();
            lastSceneCount  = EditorSceneManager.loadedSceneCount;
        }
示例#5
0
 public void merge(QObjectList anotherInstance)
 {
     lockedObjects.AddRange(anotherInstance.lockedObjects);
     editModeVisibileObjects.AddRange(anotherInstance.editModeVisibileObjects);
     editModeInvisibleObjects.AddRange(anotherInstance.editModeInvisibleObjects);
     wireframeHiddenObjects.AddRange(anotherInstance.wireframeHiddenObjects);
 }
示例#6
0
        public static QObjectList getObjectList(bool createIfNotExist = true)
        {
            if (objectList ==  null)
            {
                QObjectList[] objectListArray = (QObjectList[])GameObject.FindObjectsOfType<QObjectList>();
                for (int i = 0; i < objectListArray.Length; i++)
                {
                    if (objectListArray[i].name == ObjectListName)
                    {
                        if (objectList == null)
                        {
                            objectList = objectListArray[i];
                        }
                        else
                        {
                            objectList.merge(objectListArray[i]);
                            GameObject.DestroyImmediate(objectListArray[i].gameObject);
                        }
                    }
                }

                if (objectList == null && createIfNotExist)
                {
                    GameObject gameObjectList = new GameObject();
                    gameObjectList.name = ObjectListName;
                    gameObjectList.tag = "EditorOnly";
                    objectList = gameObjectList.AddComponent<QObjectList>();
                }
            }
            return objectList;
        }
示例#7
0
 public void merge(QObjectList anotherInstance)
 {
     lockedObjects.AddRange(anotherInstance.lockedObjects);
     editModeVisibileObjects.AddRange(anotherInstance.editModeVisibileObjects);
     editModeInvisibleObjects.AddRange(anotherInstance.editModeInvisibleObjects);
     wireframeHiddenObjects.AddRange(anotherInstance.wireframeHiddenObjects);
 }
示例#8
0
        static void Update()
        {
            try
            {
                if (!inited)
                {
                    init();
                }
                if (objectListDictionary.Count == 0 || checkSceneChanged())
                {
                    updateObjectListDictionary();
                }

                HideFlags hideFlag = QHierarchySettings.getSetting <bool>(QHierarchySetting.ShowHiddenQHierarchyObjectList) ? HideFlags.None : HideFlags.HideInHierarchy;
                foreach (KeyValuePair <Scene, QObjectList> objectListKeyValue in objectListDictionary)
                {
                    QObjectList objectList = objectListKeyValue.Value;
                    if (objectList.gameObject.hideFlags != hideFlag)
                    {
                        objectList.gameObject.hideFlags = hideFlag;
                        EditorApplication.DirtyHierarchyWindowSorting();
                    }
                }

                if (checkSelectionChanged())
                {
                    if (QHierarchySettings.getSetting <bool>(QHierarchySetting.ShowLockButton) &&
                        QHierarchySettings.getSetting <bool>(QHierarchySetting.PreventSelectionOfLockedObjects))
                    {
                        GameObject[]      selections = Selection.gameObjects;
                        List <GameObject> actual     = new List <GameObject>();
                        bool found = false;
                        for (int i = 0; i < selections.Length; i++)
                        {
                            GameObject selectedGameObject = selections[i];
                            if (objectListDictionary.ContainsKey(selectedGameObject.scene))
                            {
                                bool isLock = objectListDictionary[selectedGameObject.scene].lockedObjects.Contains(selections[i]);
                                if (!isLock)
                                {
                                    actual.Add(selections[i]);
                                }
                                else
                                {
                                    found = true;
                                }
                            }
                        }
                        if (found)
                        {
                            Selection.objects = actual.ToArray();
                        }
                    }
                }
            }
            catch
            {
                updateObjectListDictionary();
            }
        }
示例#9
0
 public static void unlockAll()
 {
     foreach (KeyValuePair <Scene, QObjectList> objectListKeyValue in objectListDictionary)
     {
         QObjectList objectList = objectListKeyValue.Value;
         for (int i = 0; i < objectList.lockedObjects.Count; i++)
         {
             objectList.lockedObjects[i].hideFlags ^= HideFlags.NotEditable;
             EditorUtility.SetDirty(objectList.lockedObjects[i]);
         }
     }
 }
示例#10
0
 static void hierarchyWindowChanged()
 {
     foreach (KeyValuePair <Scene, QObjectList> objectListKeyValue in objectListDictionary)
     {
         QObjectList objectList = objectListKeyValue.Value;
         if (objectList == null)
         {
             updateObjectListDictionary();
             return;
         }
         objectList.checkIntegrity();
     }
 }
示例#11
0
        static void Update()
        {
            if (!inited)
            {
                init();
            }

            if (objectList == null)
            {
                objectList = getObjectList(false);
                if (objectList == null)
                {
                    return;
                }
            }

            HideFlags hideFlag = QHierarchySettings.getSetting <bool>(QHierarchySetting.ShowHiddenQHierarchyObjectList) ? HideFlags.None : HideFlags.HideInHierarchy;

            #if !UNITY_4_6
            hideFlag = hideFlag | HideFlags.DontSaveInBuild;
            #endif

            if (objectList.gameObject.hideFlags != hideFlag)
            {
                objectList.gameObject.hideFlags = hideFlag;
            }

            if (QHierarchySettings.getSetting <bool>(QHierarchySetting.ShowLockButton) &&
                QHierarchySettings.getSetting <bool>(QHierarchySetting.PreventSelectionOfLockedObjects))
            {
                GameObject[]      selections = Selection.gameObjects;
                List <GameObject> actual     = new List <GameObject>();
                bool found = false;
                for (int i = 0; i < selections.Length; i++)
                {
                    bool isLock = objectList.lockedObjects.Contains(selections[i]);
                    if (!isLock)
                    {
                        actual.Add(selections[i]);
                    }
                    else
                    {
                        found = true;
                    }
                }
                if (found)
                {
                    Selection.objects = actual.ToArray();
                }
            }
        }
示例#12
0
        public static void SetVisibility(List <GameObject> gameObjects, bool visible, bool editmode)
        {
            //GameObject gameObject = (GameObject)EditorUtility.InstanceIDToObject(instanceId);
            GameObject gameObject = gameObjects[0]; // this is only used to get the instance of the scene

            if (gameObject == null)
            {
                return;
            }
            QObjectList objectList = QObjectListManager.getInstance().getObjectList(gameObject, false);

            var vc = (hierarchy.componentDictionary[(int)QHierarchyComponentEnum.VisibilityComponent] as QVisibilityComponent);

            vc.setVisibility(gameObjects, objectList, visible, editmode);
        }
示例#13
0
        public static QObjectList getObjectList(bool createIfNotExist = true)
        {
            if (objectList ==  null)
            {
                QObjectList[] objectListArray = (QObjectList[])GameObject.FindObjectsOfType<QObjectList>();
                for (int i = 0; i < objectListArray.Length; i++)
                {
                    if (objectListArray[i].name == ObjectListName)
                    {
                        if (objectList == null)
                        {
                            objectList = objectListArray[i];
                        }
                        else
                        {
                            objectList.merge(objectListArray[i]);
                            GameObject.DestroyImmediate(objectListArray[i].gameObject);
                        }
                    }
                }

                if (objectList == null && createIfNotExist)
                {
                    GameObject gameObjectList = new GameObject();
                    gameObjectList.name = ObjectListName;
                    gameObjectList.tag = "EditorOnly";
                    objectList = gameObjectList.AddComponent<QObjectList>();
                }

                if (objectList != null)
                {
                    List<GameObject> wireframeHiddenObjects = objectList.wireframeHiddenObjects;
                    foreach (GameObject gameObject in wireframeHiddenObjects)
                    {
                        Renderer renderer = gameObject.GetComponent<Renderer>();
                        if (renderer != null)
                        {
                            EditorUtility.SetSelectedWireframeHidden(renderer, true);
                        }
                    }
                }
            }
            return objectList;
        }
示例#14
0
        public static QObjectList getObjectList(bool createIfNotExist = true)
        {
            if (objectList == null)
            {
                QObjectList[] objectListArray = (QObjectList[])GameObject.FindObjectsOfType <QObjectList>();
                for (int i = 0; i < objectListArray.Length; i++)
                {
                    if (objectListArray[i].name == ObjectListName)
                    {
                        if (objectList == null)
                        {
                            objectList = objectListArray[i];
                        }
                        else
                        {
                            objectList.merge(objectListArray[i]);
                            GameObject.DestroyImmediate(objectListArray[i].gameObject);
                        }
                    }
                }

                if (objectList == null && createIfNotExist)
                {
                    GameObject gameObjectList = new GameObject();
                    gameObjectList.name = ObjectListName;
                    gameObjectList.tag  = "EditorOnly";
                    objectList          = gameObjectList.AddComponent <QObjectList>();
                }

                if (objectList != null)
                {
                    List <GameObject> wireframeHiddenObjects = objectList.wireframeHiddenObjects;
                    foreach (GameObject gameObject in wireframeHiddenObjects)
                    {
                        Renderer renderer = gameObject.GetComponent <Renderer>();
                        if (renderer != null)
                        {
                            EditorUtility.SetSelectedWireframeHidden(renderer, true);
                        }
                    }
                }
            }
            return(objectList);
        }
示例#15
0
        public void merge(QObjectList anotherInstance)
        {
            for (int i = anotherInstance.lockedObjects.Count - 1; i >= 0; i--)
            {
                if (!lockedObjects.Contains(anotherInstance.lockedObjects[i]))
                {
                    lockedObjects.Add(anotherInstance.lockedObjects[i]);
                }
            }

            for (int i = anotherInstance.editModeVisibileObjects.Count - 1; i >= 0; i--)
            {
                if (!editModeVisibileObjects.Contains(anotherInstance.editModeVisibileObjects[i]))
                {
                    editModeVisibileObjects.Add(anotherInstance.editModeVisibileObjects[i]);
                }
            }

            for (int i = anotherInstance.editModeInvisibleObjects.Count - 1; i >= 0; i--)
            {
                if (!editModeInvisibleObjects.Contains(anotherInstance.editModeInvisibleObjects[i]))
                {
                    editModeInvisibleObjects.Add(anotherInstance.editModeInvisibleObjects[i]);
                }
            }

            for (int i = anotherInstance.wireframeHiddenObjects.Count - 1; i >= 0; i--)
            {
                if (!wireframeHiddenObjects.Contains(anotherInstance.wireframeHiddenObjects[i]))
                {
                    wireframeHiddenObjects.Add(anotherInstance.wireframeHiddenObjects[i]);
                }
            }

            for (int i = anotherInstance.gameObjectColorKeys.Count - 1; i >= 0; i--)
            {
                if (!gameObjectColorKeys.Contains(anotherInstance.gameObjectColorKeys[i]))
                {
                    gameObjectColorKeys.Add(anotherInstance.gameObjectColorKeys[i]);
                    gameObjectColorValues.Add(anotherInstance.gameObjectColorValues[i]);
                    gameObjectColor.Add(anotherInstance.gameObjectColorKeys[i], anotherInstance.gameObjectColorValues[i]);
                }
            }
        }
示例#16
0
        public void merge(QObjectList anotherInstance)
        {
            for (int i = anotherInstance.lockedObjects.Count - 1; i >= 0; i--)
            {
                if (!lockedObjects.Contains(anotherInstance.lockedObjects[i]))
                    lockedObjects.Add(anotherInstance.lockedObjects[i]);
            }

            for (int i = anotherInstance.editModeVisibileObjects.Count - 1; i >= 0; i--)
            {
                if (!editModeVisibileObjects.Contains(anotherInstance.editModeVisibileObjects[i]))
                    editModeVisibileObjects.Add(anotherInstance.editModeVisibileObjects[i]);
            }

            for (int i = anotherInstance.editModeInvisibleObjects.Count - 1; i >= 0; i--)
            {
                if (!editModeInvisibleObjects.Contains(anotherInstance.editModeInvisibleObjects[i]))
                    editModeInvisibleObjects.Add(anotherInstance.editModeInvisibleObjects[i]);
            }

            for (int i = anotherInstance.wireframeHiddenObjects.Count - 1; i >= 0; i--)
            {
                if (!wireframeHiddenObjects.Contains(anotherInstance.wireframeHiddenObjects[i]))
                    wireframeHiddenObjects.Add(anotherInstance.wireframeHiddenObjects[i]);
            }

            for (int i = anotherInstance.gameObjectColorKeys.Count - 1; i >= 0; i--)
            {
                if (!gameObjectColorKeys.Contains(anotherInstance.gameObjectColorKeys[i]))
                {
                    gameObjectColorKeys.Add(anotherInstance.gameObjectColorKeys[i]);
                    gameObjectColorValues.Add(anotherInstance.gameObjectColorValues[i]);
                    gameObjectColor.Add(anotherInstance.gameObjectColorKeys[i], anotherInstance.gameObjectColorValues[i]);
                }
            }
        }
示例#17
0
        static void setVisibility(QObjectList objectList, List <GameObject> gameObjects, bool targetVisibility, bool editMode)
        {
            for (int i = gameObjects.Count - 1; i >= 0; i--)
            {
                GameObject curGameObject = gameObjects[i];
                Undo.RecordObject(curGameObject, "visibility change");

                if (editMode)
                {
                    if (!targetVisibility)
                    {
                        objectList.editModeVisibileObjects.Remove(curGameObject);
                        if (!objectList.editModeInvisibleObjects.Contains(curGameObject))
                        {
                            objectList.editModeInvisibleObjects.Add(curGameObject);
                        }
                    }
                    else
                    {
                        objectList.editModeInvisibleObjects.Remove(curGameObject);
                        if (!objectList.editModeVisibileObjects.Contains(curGameObject))
                        {
                            objectList.editModeVisibileObjects.Add(curGameObject);
                        }
                    }
                }
                else if (objectList != null)
                {
                    objectList.editModeVisibileObjects.Remove(curGameObject);
                    objectList.editModeInvisibleObjects.Remove(curGameObject);
                }

                curGameObject.SetActive(targetVisibility);
                EditorUtility.SetDirty(curGameObject);
            }
        }
示例#18
0
        static float drawWireframeButton(QObjectList objectList, 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, "renderer visibility change");

                    if (Event.current.control || Event.current.command)
                    {
                        if (!wireframeHiddenObjectsContains)
                        {
                            EditorUtility.SetSelectedWireframeHidden(renderer, true);
                            SceneView.RepaintAll();

                            if (objectList == null)
                            {
                                objectList = createObjectListInScene(gameObject.scene);
                            }
                            Undo.RecordObject(objectList, "renderer visibility change");
                            objectList.wireframeHiddenObjects.Add(gameObject);
                            EditorUtility.SetDirty(objectList);
                        }
                    }
                    else
                    {
                        if (wireframeHiddenObjectsContains)
                        {
                            EditorUtility.SetSelectedWireframeHidden(renderer, false);
                            SceneView.RepaintAll();

                            if (objectList != null)
                            {
                                Undo.RecordObject(renderer, "renderer visibility change");
                                objectList.wireframeHiddenObjects.Remove(gameObject);
                                EditorUtility.SetDirty(objectList);
                            }
                        }
                        else
                        {
                            renderer.enabled = !isEnabled;
                        }
                    }

                    EditorUtility.SetDirty(gameObject);
                }
                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);
        }
示例#19
0
        static void DrawHierarchyItemIcon(int instanceId, Rect selectionRect)
        {
            try
            {
                GameObject itemGameObject = (GameObject)EditorUtility.InstanceIDToObject(instanceId);
                if (itemGameObject == null)
                {
                    return;
                }

                if (QHierarchySettings.getSetting <bool>(QHierarchySetting.ShowTreeMap) ||
                    QHierarchySettings.getSetting <bool>(QHierarchySetting.ShowMonoBehaviourIcon))
                {
                    drawTreeMap(itemGameObject, selectionRect);
                }

                Rect rect = new Rect(selectionRect);
                rect.width = 16;
                rect.x    += selectionRect.width - QHierarchySettings.getSetting <int>(QHierarchySetting.Identation);

                List <QHierarchyIconType> iconOrder = QHierarchySettings.getSetting <List <QHierarchyIconType> >(QHierarchySetting.IconOrder);
                QObjectList objectList = objectListDictionary.ContainsKey(itemGameObject.scene) ? objectListDictionary[itemGameObject.scene] : null;

                for (int i = iconOrder.Count - 1; i >= 0; i--)
                {
                    switch (iconOrder[i])
                    {
                    case QHierarchyIconType.LockButton:
                    {
                        if (QHierarchySettings.getSetting <bool>(QHierarchySetting.ShowLockButton))
                        {
                            rect.x -= drawLockButton(objectList, itemGameObject, rect);
                        }
                        break;
                    }

                    case QHierarchyIconType.VisibilityButton:
                    {
                        if (QHierarchySettings.getSetting <bool>(QHierarchySetting.ShowVisibilityButton))
                        {
                            rect.x -= drawVisibilityButton(objectList, itemGameObject, rect);
                        }
                        break;
                    }

                    case QHierarchyIconType.MeshButton:
                    {
                        if (QHierarchySettings.getSetting <bool>(QHierarchySetting.ShowMeshButton))
                        {
                            rect.x -= drawWireframeButton(objectList, itemGameObject, rect);
                        }
                        break;
                    }

                    case QHierarchyIconType.TagAndLayer:
                    {
                        if (QHierarchySettings.getSetting <bool>(QHierarchySetting.ShowTagAndLayerText))
                        {
                            rect.x -= drawTagLayerText(itemGameObject, rect);
                        }
                        break;
                    }

                    case QHierarchyIconType.ErrorIcon:
                    {
                        if (QHierarchySettings.getSetting <bool>(QHierarchySetting.ShowErrorIcon))
                        {
                            rect.x -= drawErrorIcon(itemGameObject, rect);
                        }
                        break;
                    }

                    case QHierarchyIconType.GameObjectIcon:
                    {
                        if (QHierarchySettings.getSetting <bool>(QHierarchySetting.ShowGameObjectIcon))
                        {
                            float offset = drawGameObjectIcon(itemGameObject, rect);

                            if (QHierarchySettings.getSetting <bool>(QHierarchySetting.CustomTagIconReplace))
                            {
                                drawCustomTagIcon(itemGameObject, rect);
                            }

                            rect.x -= offset;
                        }
                        break;
                    }

                    case QHierarchyIconType.CustomTagIcon:
                    {
                        if (QHierarchySettings.getSetting <bool>(QHierarchySetting.ShowCustomTagIcon) &&
                            !QHierarchySettings.getSetting <bool>(QHierarchySetting.CustomTagIconReplace))
                        {
                            rect.x -= drawCustomTagIcon(itemGameObject, rect);
                        }
                        break;
                    }

                    case QHierarchyIconType.StaticIcon:
                    {
                        if (QHierarchySettings.getSetting <bool>(QHierarchySetting.ShowStaticIcon))
                        {
                            rect.x -= drawStaticIcon(itemGameObject, rect);
                        }
                        break;
                    }
                    }
                }
            }
            catch
            {
                updateObjectListDictionary();
            }
        }
示例#20
0
        static float drawVisibilityButton(QObjectList objectList, 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();
                bool showWarning = QHierarchySettings.getSetting <bool>(QHierarchySetting.ShowModifierWarning);

                List <GameObject> targetGameObjects = new List <GameObject>();
                if (Event.current.control || Event.current.command)
                {
                    if (objectList == null)
                    {
                        objectList = createObjectListInScene(gameObject.scene);
                    }

                    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"))
                        {
                            getGameObjectListRecursive(ref targetGameObjects, gameObject);
                        }
                    }
                    else if (Event.current.alt)
                    {
                        if (gameObject.transform.parent != null)
                        {
                            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"))
                            {
                                getGameObjectListRecursive(ref targetGameObjects, gameObject.transform.parent.gameObject, 1);
                                targetGameObjects.Remove(gameObject.transform.parent.gameObject);
                            }
                        }
                        else
                        {
                            gameObject.scene.GetRootGameObjects(targetGameObjects);
                        }
                    }
                    else
                    {
                        getGameObjectListRecursive(ref targetGameObjects, gameObject, 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"))
                    {
                        getGameObjectListRecursive(ref targetGameObjects, gameObject);
                    }
                }
                else if (Event.current.alt)
                {
                    if (gameObject.transform.parent != null)
                    {
                        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"))
                        {
                            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);
                    };
                }

                if (objectList != null)
                {
                    Undo.RecordObject(objectList, "visibility change");
                }
                setVisibility(objectList, targetGameObjects, !gameObject.activeSelf, Event.current.control || Event.current.command);
            }

            return(rect.width);
        }
示例#21
0
        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);
        }