Пример #1
0
        void OnEnable()
        {
            rootVisualElement.StyleBorderWidth(1);
            Color c = new Color32(58, 121, 187, 255);

            rootVisualElement.StyleBorderColor(c);

            // EditorHelpBox helpBox = new EditorHelpBox("This feature currently in preview state", MessageType.Info);
            // rootVisualElement.Add(helpBox);

            hierarchyLocalData         = HierarchyEditor.Instance.GetHierarchyLocalData(Selection.activeGameObject.scene);
            gameObject                 = Selection.activeGameObject;
            Selection.activeGameObject = null;

            CustomRowItem customRowItem = null;

            if (hierarchyLocalData.TryGetCustomRowData(gameObject, out customRowItem) == false)
            {
                customRowItem = hierarchyLocalData.CreateCustomRowItemFor(gameObject);
            }
            DlfU.UIElements.Toggle useBackground = new DlfU.UIElements.Toggle("Use Background",
                                                                              customRowItem.useBackground,
                                                                              Justify.FlexStart,
                                                                              (evt) =>
            {
                customRowItem.useBackground = evt.newValue;
                EditorApplication.RepaintHierarchyWindow();
            });
            rootVisualElement.Add(useBackground);

            EnumField backgroundStyle = new EnumField(customRowItem.backgroundStyle);

            backgroundStyle.label = "Background Style";
            backgroundStyle.RegisterValueChangedCallback((evt) =>
            {
                customRowItem.backgroundStyle = (CustomRowItem.BackgroundStyle)evt.newValue;
                EditorApplication.RepaintHierarchyWindow();
            });
            rootVisualElement.Add(backgroundStyle);

            EnumField backgroundMode = new EnumField(customRowItem.backgroundMode);

            backgroundMode.label = "Background Mode";
            backgroundMode.RegisterValueChangedCallback((evt) =>
            {
                customRowItem.backgroundMode = (CustomRowItem.BackgroundMode)evt.newValue;
                EditorApplication.RepaintHierarchyWindow();
            });
            rootVisualElement.Add(backgroundMode);

            ColorField backgroundColor = new ColorField("Background Color");

            backgroundColor.value = customRowItem.backgroundColor;
            backgroundColor.RegisterValueChangedCallback((evt) =>
            {
                customRowItem.backgroundColor = evt.newValue;
                EditorApplication.RepaintHierarchyWindow();
            });
            rootVisualElement.Add(backgroundColor);
        }
Пример #2
0
        void OnEnable()
        {
            rootVisualElement.StyleMargin(4, 4, 2, 0);

            hierarchyLocalData         = HierarchyEditor.Instance.GetHierarchyLocalData(Selection.activeGameObject.scene);
            gameObject                 = Selection.activeGameObject;
            Selection.activeGameObject = null;

            CustomRowItem customRowItem = null;

            if (hierarchyLocalData.TryGetCustomRowData(gameObject, out customRowItem) == false)
            {
                customRowItem = hierarchyLocalData.CreateCustomRowItemFor(gameObject);
            }


            IMGUIContainer iMGUIContainer = new IMGUIContainer(() =>
            {
                customRowItem.useBackground = EditorGUILayout.Toggle("Background", customRowItem.useBackground);

                customRowItem.backgroundStyle = (CustomRowItem.BackgroundStyle)EditorGUILayout.EnumPopup("Background Style", customRowItem.backgroundStyle);
                customRowItem.backgroundMode  = (CustomRowItem.BackgroundMode)EditorGUILayout.EnumPopup("Background Mode", customRowItem.backgroundMode);
                customRowItem.backgroundColor = EditorGUILayout.ColorField("Background Color", customRowItem.backgroundColor);

                customRowItem.overrideLabel = EditorGUILayout.Toggle("Override Label", customRowItem.overrideLabel);

                var wideMode = EditorGUIUtility.wideMode;
                EditorGUIUtility.wideMode = true;
                customRowItem.labelOffset = EditorGUILayout.Vector2Field("Label Offset", customRowItem.labelOffset);
                EditorGUIUtility.wideMode = wideMode;
                customRowItem.labelColor  = EditorGUILayout.ColorField("Label Color", customRowItem.labelColor);

                if (GUI.changed)
                {
                    EditorApplication.RepaintHierarchyWindow();
                }
            });

            rootVisualElement.Add(iMGUIContainer);
        }
 public static bool GetInstance(Scene scene, out HierarchyLocalData hierarchyLocalData)
 {
     return(instances.TryGetValue(scene, out hierarchyLocalData));
 }
Пример #4
0
 private void OnEnable()
 {
     hld = target as HierarchyLocalData;
 }
Пример #5
0
        void OnEnable()
        {
            if (gameObjects == null)
            {
                return;
            }

            List <GameObject> _gameObjects = new List <GameObject>(gameObjects);

            _gameObjects.RemoveAll((gameObject) => gameObject == null);
            if (_gameObjects.Count == 0) // All GameObjects are destroyed
            {
                Close();
                return;
            }

            rootVisualElement.StyleMargin(4, 4, 2, 0);

            customRowItems = new CustomRowItem[_gameObjects.Count];

            List <HierarchyLocalData> _hierarchyLocalDatas = new List <HierarchyLocalData>(2);

            for (int i = 0; i < _gameObjects.Count; i++)
            {
                if (_gameObjects[i] == null)
                {
                    continue;
                }

                HierarchyLocalData hierarchyLocalData = HierarchyEditor.Instance.GetHierarchyLocalData(_gameObjects[i].scene);

                CustomRowItem customRowItem;
                if (hierarchyLocalData.TryGetCustomRowData(_gameObjects[i], out customRowItem) == false)
                {
                    customRowItem = hierarchyLocalData.CreateCustomRowItemFor(_gameObjects[i]);
                }

                customRowItems[i] = customRowItem;

                if (!_hierarchyLocalDatas.Contains(hierarchyLocalData))
                {
                    _hierarchyLocalDatas.Add(hierarchyLocalData);
                }
            }

            hierarchyLocalDatas = _hierarchyLocalDatas.ToArray();

            IMGUIContainer iMGUIContainer = new IMGUIContainer(() =>
            {
                if (hierarchyLocalDatas == null || EditorApplication.isCompiling)
                {
                    Close();
                    return;
                }

                for (int i = 0; i < hierarchyLocalDatas.Length; i++)
                {
                    if (hierarchyLocalDatas[i] == null) // A scene is closed or user has deleted HierarchyLocalData manually
                    {
                        Close();
                        return;
                    }
                }

                var wideMode                = EditorGUIUtility.wideMode;
                var labelWidth              = EditorGUIUtility.labelWidth;
                EditorGUIUtility.wideMode   = true;
                EditorGUIUtility.labelWidth = 140f;

                EditorGUI.showMixedValue = CheckMultipleDifferentValues((customRowItem1, customRowItem2) => customRowItem1.useBackground == customRowItem2.useBackground);
                bool useBackground       = EditorGUILayout.Toggle("Background", customRowItems[0].useBackground);
                ApplyModifiedProperties((customRowItem) => customRowItem.useBackground = useBackground);

                GUI.enabled = useBackground || EditorGUI.showMixedValue;
                EditorGUI.indentLevel++;

                EditorGUI.showMixedValue = CheckMultipleDifferentValues((customRowItem1, customRowItem2) => customRowItem1.backgroundStyle == customRowItem2.backgroundStyle);
                CustomRowItem.BackgroundStyle backgroundStyle = (CustomRowItem.BackgroundStyle)EditorGUILayout.EnumPopup("Background Style", customRowItems[0].backgroundStyle);
                ApplyModifiedProperties((customRowItem) => customRowItem.backgroundStyle = backgroundStyle);

                EditorGUI.showMixedValue = CheckMultipleDifferentValues((customRowItem1, customRowItem2) => customRowItem1.backgroundMode == customRowItem2.backgroundMode);
                CustomRowItem.BackgroundMode backgroundMode = (CustomRowItem.BackgroundMode)EditorGUILayout.EnumPopup("Background Mode", customRowItems[0].backgroundMode);
                ApplyModifiedProperties((customRowItem) => customRowItem.backgroundMode = backgroundMode);

                EditorGUI.showMixedValue = CheckMultipleDifferentValues((customRowItem1, customRowItem2) => customRowItem1.backgroundColor == customRowItem2.backgroundColor);
                Color backgroundColor    = EditorGUILayout.ColorField("Background Color", customRowItems[0].backgroundColor);
                ApplyModifiedProperties((customRowItem) => customRowItem.backgroundColor = backgroundColor);

                EditorGUI.indentLevel--;
                GUI.enabled = true;

                EditorGUI.showMixedValue = CheckMultipleDifferentValues((customRowItem1, customRowItem2) => customRowItem1.overrideLabel == customRowItem2.overrideLabel);
                bool overrideLabel       = EditorGUILayout.Toggle("Override Label", customRowItems[0].overrideLabel);
                ApplyModifiedProperties((customRowItem) => customRowItem.overrideLabel = overrideLabel);

                GUI.enabled = overrideLabel || EditorGUI.showMixedValue;
                EditorGUI.indentLevel++;

                EditorGUI.showMixedValue = CheckMultipleDifferentValues((customRowItem1, customRowItem2) => customRowItem1.labelOffset == customRowItem2.labelOffset);
                Vector2 labelOffset      = EditorGUILayout.Vector2Field("Label Offset", customRowItems[0].labelOffset);
                ApplyModifiedProperties((customRowItem) => customRowItem.labelOffset = labelOffset);

                EditorGUI.showMixedValue = CheckMultipleDifferentValues((customRowItem1, customRowItem2) => customRowItem1.labelColor == customRowItem2.labelColor);
                Color labelColor         = EditorGUILayout.ColorField("Label Color", customRowItems[0].labelColor);
                ApplyModifiedProperties((customRowItem) => customRowItem.labelColor = labelColor);

                EditorGUI.indentLevel--;
                GUI.enabled = true;

                EditorGUI.showMixedValue    = false;
                EditorGUIUtility.wideMode   = wideMode;
                EditorGUIUtility.labelWidth = labelWidth;
            });

            rootVisualElement.Add(iMGUIContainer);

            Undo.undoRedoPerformed -= Repaint;
            Undo.undoRedoPerformed += Repaint;
        }