예제 #1
0
        public FloatField AddFloatField(float value = 0f, bool alternate = false, bool secondAlternate = false, bool thirdAlternate = false)
        {
            FloatField el = new FloatField();

            el.value = value;
            el.AddToClassList("list-item-input");
            el.AddToClassList("list-item-float-input");
            AddAlternates(el, alternate, secondAlternate, thirdAlternate);
            el.RegisterValueChangedCallback(e => {
                eventManager.Raise <ListItemInputChange>(new ListItemInputChange(el));
            });
            this.Add(el);
            return(el);
        }
예제 #2
0
        VisualElement CreateSliderWithField(GUIContent label, float value, float min, float max, EventCallback <ChangeEvent <float> > callback)
        {
            var root = new VisualElement()
            {
                name = "Slider Float Field"
            };

            root.AddToClassList(k_SliderRowClass);

            var slider = new Slider(min, max);

            slider.AddToClassList(k_SliderClass);
            slider.RegisterValueChangedCallback(callback);
            slider.SetValueWithoutNotify(value);

            if (label != null && !string.IsNullOrEmpty(label.text))
            {
                slider.label   = label.text;
                slider.tooltip = label.tooltip;
            }

            var field = new FloatField();

            field.AddToClassList(k_SliderFloatFieldClass);
            field.RegisterValueChangedCallback(callback);
            field.SetValueWithoutNotify(value);

            root.Add(slider);
            root.Add(field);

            return(root);
        }
        public BaseNodeUI()
        {
            VisualElement container = new VisualElement();

            title = DefaultName;
            Label titleLabel = (Label)titleContainer[0];

            titleContainer.RemoveAt(0);

            NameField = new TextField();
            NameField.style.flexGrow = 1f;

            container.Add(titleLabel);
            container.Add(NameField);

            titleContainer.Insert(0, container);

            _speedField = new FloatField("Speed");
            _speedField.SetValueWithoutNotify(1f);
            _speedField.AddToClassList("speed-field");
            mainContainer.Insert(1, _speedField);

            RefreshExpandedState();
            RefreshPorts();
        }
예제 #4
0
        VisualElement CreateLightExposureContent()
        {
            var exposure = SceneView.s_DrawModeExposure;

            var root = new VisualElement();

            root.AddToClassList(k_SliderRowClass);

            var icon = new Image()
            {
                name = "exposure-label"
            };

            m_ExposureSlider = new Slider(-m_ExposureMax, m_ExposureMax)
            {
                name = "exposure-slider"
            };
            m_ExposureSlider.AddToClassList(k_SliderClass);
            m_ExposureSlider.RegisterValueChangedCallback(SetBakedExposure);
            m_ExposureSlider.SetValueWithoutNotify(exposure);

            m_ExposureField = new FloatField()
            {
                name = "exposure-float-field"
            };
            m_ExposureField.AddToClassList(k_SliderFloatFieldClass);
            m_ExposureField.RegisterValueChangedCallback(SetBakedExposure);
            m_ExposureField.SetValueWithoutNotify(exposure);

            root.Add(icon);
            root.Add(m_ExposureSlider);
            root.Add(m_ExposureField);
            return(root);
        }
        void LoadTemplate()
        {
            AddToClassList("timeField");
            m_FieldName = new Label();
            m_FieldName.AddToClassList("timeFieldNameLabel");
            Add(m_FieldName);
            var inputContainer = new VisualElement();

            inputContainer.AddToClassList("timeFieldInputContainer");
            Add(inputContainer);

            m_SecondsField = new FloatField("Seconds");
            m_SecondsField.AddToClassList("timeInput");
            m_SecondsField.RegisterValueChangedCallback(OnTimeInSecondsChanged);
            inputContainer.Add(m_SecondsField);

            m_FrameField = new IntegerField("Frame");
            m_FrameField.AddToClassList("timeInput");
            m_FrameField.RegisterValueChangedCallback(OnFrameChanged);
            inputContainer.Add(m_FrameField);

            SyncToViewModeSetting();

            RegisterCallback <AttachToPanelEvent>(OnAttachToPanel);
            RegisterCallback <DetachFromPanelEvent>(OnDetachFromPanel);
        }
예제 #6
0
        public Slider(
            float val,
            float min,
            float max,
            EventCallback <float> valueCB,
            EventCallback <float> minCB,
            EventCallback <float> maxCB
            )
        {
            ValueCallback = valueCB;
            MinCallback   = minCB;
            MaxCallback   = maxCB;

            Value = val;

            contentContainer.AddToClassList("bounded-float");
            contentContainer.AddToClassList("range");

            Range = new SliderFloat {
                highValue = max,
                lowValue  = min,
                value     = val
            };

            Min = new FloatField {
                value = min
            };
            Current = new FloatField {
                value = val
            };
            Max = new FloatField {
                value = max
            };

            Min.AddToClassList("min-value");
            Current.AddToClassList("current-value");
            Max.AddToClassList("max-value");

            var Fields = new VisualElement();

            Fields.AddToClassList("input-fields");

            Fields.Add(Min);
            Fields.Add(Current);
            Fields.Add(Max);

            contentContainer.Add(Range);
            contentContainer.Add(Fields);

            Range.RegisterValueChangedCallback(CurrentChanged);
            Min.RegisterValueChangedCallback(MinChanged);
            Current.RegisterValueChangedCallback(CurrentChanged);
            Max.RegisterValueChangedCallback(MaxChanged);
        }
예제 #7
0
        public MinMaxSliderControl(Vector2 value, float min, float max)
        {
            _slider = new MinMaxSlider(value.x, value.y, min, max);

            _minText = new FloatField();
            _minText.RegisterValueChangedCallback(evt => this.SendChangeEvent(evt.previousValue, evt.newValue));
            _minText.AddToClassList(TextUssClassName);

            _maxText = new FloatField();
            _maxText.RegisterValueChangedCallback(evt => this.SendChangeEvent(evt.previousValue, evt.newValue));
            _maxText.AddToClassList(TextUssClassName);

            Add(_minText);
            Setup(value);
            Add(_maxText);
        }
예제 #8
0
        internal override void Apply(VisualElement container)
        {
            /// <sample>
            // Get a reference to the field from UXML and assign it its value.
            var uxmlField = container.Q <FloatField>("the-uxml-field");

            uxmlField.value = 42.4f;

            // Create a new field, disable it, and give it a style class.
            var csharpField = new FloatField("C# Field");

            csharpField.SetEnabled(false);
            csharpField.AddToClassList("some-styled-field");
            csharpField.value = uxmlField.value;
            container.Add(csharpField);

            // Mirror value of uxml field into the C# field.
            uxmlField.RegisterCallback <ChangeEvent <float> >((evt) =>
            {
                csharpField.value = evt.newValue;
            });
            /// </sample>
        }
예제 #9
0
 private static void SetInputClass(FloatField field, string label)
 {
     field.AddToClassList(label);
 }
예제 #10
0
        public override VisualElement CreatePropertyGUI(SerializedProperty property)
        {
            VisualElement root = new VisualElement();

            Foldout foldout = new Foldout {
                text = property.displayName, value = property.isExpanded
            };

            foldout.RegisterValueChangedCallback((evt) => { property.isExpanded = foldout.value; });

            elements = new VisualElement();
            foldout.contentContainer.Add(elements);

            enabled     = new PropertyField(property.FindPropertyRelative("enabled"));
            randomPitch = new PropertyField(property.FindPropertyRelative("randomPitch"));
            pitch       = new PropertyField(property.FindPropertyRelative("pitch"));

            randomPitchElements = new VisualElement();
            randomPitchElements.AddToClassList("unity-property-field");

            VisualElement basePitchFields = new VisualElement();

            basePitchFields.AddToClassList("unity-base-field");
            basePitchFields.AddToClassList("unity-base-text-field");
            basePitchFields.AddToClassList("unity-float-field");

            Label pitchLabel = new Label("Pitch");

            pitchLabel.AddToClassList("unity-text-element");
            pitchLabel.AddToClassList("unity-label");
            pitchLabel.AddToClassList("unity-base-field__label");
            pitchLabel.AddToClassList("unity-base-text-field__label");
            pitchLabel.AddToClassList("unity-float-field__label");
            pitchLabel.AddToClassList("unity-property-field__label");

            FloatField minPitchField = new FloatField
            {
                bindingPath = property.FindPropertyRelative("minPitch").propertyPath,
            };

            minPitchField.style.flexGrow = 1;
            minPitchField.AddToClassList("unity-property-field__input");

            FloatField maxPitchField = new FloatField
            {
                bindingPath = property.FindPropertyRelative("maxPitch").propertyPath,
            };

            maxPitchField.style.flexGrow = 1;
            maxPitchField.AddToClassList("unity-property-field__input");

            VisualElement pitchFields = new VisualElement()
            {
                name = "pitch-fields"
            };

            pitchFields.style.flexDirection = FlexDirection.Row;
            pitchFields.style.flexGrow      = 1;

            Label minLabel = new Label("Min");

            minLabel.AddToClassList("unity-text-element");
            minLabel.AddToClassList("unity-label");
            minLabel.style.unityTextAlign = TextAnchor.MiddleLeft;

            pitchFields.Add(minLabel);
            pitchFields.Add(minPitchField);

            Label maxLabel = new Label("Max");

            maxLabel.AddToClassList("unity-text-element");
            maxLabel.AddToClassList("unity-label");
            maxLabel.style.unityTextAlign = TextAnchor.MiddleLeft;

            pitchFields.Add(maxLabel);
            pitchFields.Add(maxPitchField);

            basePitchFields.Add(pitchLabel);
            basePitchFields.Add(pitchFields);

            randomPitchElements.Add(basePitchFields);

            changeVolume = new PropertyField(property.FindPropertyRelative("changeVolume"));
            volume       = new PropertyField(property.FindPropertyRelative("volume"));
            audioClips   = new PropertyField(property.FindPropertyRelative("audioClips"));

            elements.Add(enabled);
            elements.Add(randomPitch);
            elements.Add(pitch);
            elements.Add(randomPitchElements);
            elements.Add(changeVolume);
            elements.Add(volume);
            elements.Add(audioClips);

            enabled.RegisterCallback <ChangeEvent <bool> >(x => ToggleEnabled(x.newValue));
            randomPitch.RegisterCallback <ChangeEvent <bool> >(x => ToggleRandomPitch(x.newValue));
            changeVolume.RegisterCallback <ChangeEvent <bool> >(x => ToggleVolume(x.newValue));

            ToggleEnabled(property.FindPropertyRelative("enabled").boolValue);
            ToggleRandomPitch(property.FindPropertyRelative("randomPitch").boolValue);
            ToggleVolume(property.FindPropertyRelative("changeVolume").boolValue);

            root.Add(foldout);

            return(root);
        }
        private void RefreshUI()
        {
            rootVisualElement.Clear();

            VisualElement topRowElement = new VisualElement();

            topRowElement.AddToClassList("svbm-row");
            rootVisualElement.Add(topRowElement);

            Button refreshButton = new Button(RefreshUI)
            {
                name = "Refresh", text = "Refresh"
            };

            refreshButton.AddToClassList("svbm-cell");
            topRowElement.Add(refreshButton);

            Button saveButton = new Button(() => Bookmarks.Instance?.SaveToJson(Bookmarks.path))
            {
                name = "Save", text = "Save"
            };

            saveButton.AddToClassList("svbm-cell");
            topRowElement.Add(saveButton);

            IMGUIContainer header = new IMGUIContainer(OnCustomGUI);

            header.AddToClassList("sceneLightingButton");
            rootVisualElement.Add(header);

            if (Bookmarks.Count == 0)
            {
                return;
            }


            for (int i = 0; i < Bookmarks.Count; i++)
            {
                var index = i;

                VisualElement bookmarkElement = new VisualElement();
                bookmarkElement.AddToClassList("svbm-row");

                Button loadButton = new Button(() => Bookmarks.Instance[index].Load(SceneView.lastActiveSceneView))
                {
                    name = "LOAD", text = "LOAD"
                };
                loadButton.AddToClassList("svbm-cell-button");
                bookmarkElement.Add(loadButton);

                Button updateButton = new Button(() => Bookmarks.Instance[index].Save(SceneView.lastActiveSceneView))
                {
                    name = "UPDATE", text = "UPDATE"
                };
                updateButton.AddToClassList("svbm-cell-button");
                bookmarkElement.Add(updateButton);

                Button deleteButton = new Button(() =>
                {
                    Bookmarks.Instance.viewpoints.RemoveAt(index);
                    RefreshUI();
                })
                {
                    name = "DELETE", text = "DELETE"
                };
                deleteButton.AddToClassList("svbm-cell-button");
                bookmarkElement.Add(deleteButton);

                TextField nameField = new TextField("")
                {
                    tooltip = "Set this bookmark's menu path / name.\nUse '/' to create a submenu."
                };
                nameField.value = Bookmarks.Instance[index].name;
                nameField.AddToClassList("svbm-cell-text");
                nameField.RegisterValueChangedCallback((x) => Bookmarks.Instance[index].name = x.newValue);
                bookmarkElement.Add(nameField);

                MaskField overridesMask = new MaskField(Enum.GetNames(typeof(Viewpoint.Overrides)).ToList(), (int)Bookmarks.Instance[index].overrides)
                {
                    tooltip = "Set this bookmark's Overrides."
                };
                overridesMask.AddToClassList("svbm-cell-mask");
                overridesMask.RegisterValueChangedCallback((x) => Bookmarks.Instance[index].overrides = (Viewpoint.Overrides)x.newValue);
                bookmarkElement.Add(overridesMask);

                Toggle orthoToggle = new Toggle("")
                {
                    tooltip = "Enable to set this bookmark's SceneView to Orthographic."
                };
                orthoToggle.value = Bookmarks.Instance[index].settings.ortho;
                orthoToggle.AddToClassList("svbm-cell-checkbox");
                orthoToggle.RegisterValueChangedCallback((x) => Bookmarks.Instance[index].settings.ortho = x.newValue);
                bookmarkElement.Add(orthoToggle);

                Toggle is2dToggle = new Toggle("")
                {
                    tooltip = "Enable to set this bookmark's SceneView to 2D Mode."
                };
                is2dToggle.value = Bookmarks.Instance[index].settings.is2D;
                is2dToggle.AddToClassList("svbm-cell-checkbox");
                is2dToggle.RegisterValueChangedCallback((x) => Bookmarks.Instance[index].settings.is2D = x.newValue);
                bookmarkElement.Add(is2dToggle);

                FloatField fovField = new FloatField()
                {
                    tooltip = "Set this bookmark's Camera Field of View."
                };
                fovField.value = Bookmarks.Instance[index].settings.fov;
                fovField.AddToClassList("svbm-cell-float");
                fovField.RegisterValueChangedCallback((x) => Bookmarks.Instance[index].settings.fov = Mathf.Clamp(x.newValue, 4, 120));
                bookmarkElement.Add(fovField);

                EnumField cameraModeMask = new EnumField("", Bookmarks.Instance[index].settings.mode.drawMode)
                {
                    tooltip = "Set this bookmark's Camera Shading Mode."
                };
                cameraModeMask.AddToClassList("svbm-cell-mask");
                // Catching cases where SceneView.GetBuiltinCameraMode() will fail on some DrawCameraMode such as Normal and User Defined
                cameraModeMask.RegisterValueChangedCallback((x) => {
                    try
                    {
                        Bookmarks.Instance[index].settings.mode = SceneView.GetBuiltinCameraMode((DrawCameraMode)x.newValue);
                    }
                    catch
                    {
                        cameraModeMask.SetValueWithoutNotify(x.previousValue);
                    }
                });
                bookmarkElement.Add(cameraModeMask);

                Toggle lightingToggle = new Toggle("")
                {
                    tooltip = "Enable this bookmark's SceneView Lighting."
                };
                lightingToggle.value = Bookmarks.Instance[index].settings.sceneLighting;
                lightingToggle.AddToClassList("svbm-cell-checkbox");
                lightingToggle.RegisterValueChangedCallback((x) => Bookmarks.Instance[index].settings.sceneLighting = x.newValue);
                bookmarkElement.Add(lightingToggle);

                MaskField viewStatesMask = new MaskField(SceneViewStatesLabels, (int)Bookmarks.Instance[index].settings.sceneViewState.GetFlags())
                {
                    tooltip = "Set this bookmark's SceneView States."
                };
                viewStatesMask.AddToClassList("svbm-cell-mask");
                viewStatesMask.RegisterValueChangedCallback((x) => Bookmarks.Instance[index].settings.sceneViewState.SetFlags((SceneViewExtensions.SceneViewStateFlags)x.newValue));
                bookmarkElement.Add(viewStatesMask);

                Toggle gridToggle = new Toggle("")
                {
                    tooltip = "Enable this bookmark's SceneView Grid."
                };
                gridToggle.value = Bookmarks.Instance[index].settings.showGrid;
                gridToggle.AddToClassList("svbm-cell-checkbox");
                gridToggle.RegisterValueChangedCallback((x) => Bookmarks.Instance[index].settings.showGrid = x.newValue);
                bookmarkElement.Add(gridToggle);

                Toggle gizmosToggle = new Toggle("")
                {
                    tooltip = "Enable this bookmark's SceneView Gizmos."
                };
                gizmosToggle.value = Bookmarks.Instance[index].settings.drawGizmos;
                gizmosToggle.AddToClassList("svbm-cell-checkbox");
                gizmosToggle.RegisterValueChangedCallback((x) => Bookmarks.Instance[index].settings.drawGizmos = x.newValue);
                bookmarkElement.Add(gizmosToggle);

                LayerMaskField visibleLayerMask = new LayerMaskField("", Bookmarks.Instance[index].visibleLayers)
                {
                    tooltip = "Set this bookmark's Visible Layers."
                };
                visibleLayerMask.AddToClassList("svbm-cell-mask");
                visibleLayerMask.RegisterValueChangedCallback((x) => Bookmarks.Instance[index].visibleLayers = x.newValue);
                bookmarkElement.Add(visibleLayerMask);

                LayerMaskField lockedLayerMask = new LayerMaskField("", Bookmarks.Instance[index].lockedLayers)
                {
                    tooltip = "Set this bookmark's Locked Layers."
                };
                lockedLayerMask.AddToClassList("svbm-cell-mask");
                lockedLayerMask.RegisterValueChangedCallback((x) => Bookmarks.Instance[index].lockedLayers = x.newValue);
                bookmarkElement.Add(lockedLayerMask);

                EnumField shortcutMask = new EnumField("", Bookmarks.Instance[index].shortcut)
                {
                    tooltip = "Set this bookmark's shortcut\nBeware this will override any other function the shortcut is associated with."
                };
                shortcutMask.AddToClassList("svbm-cell-mask");
                shortcutMask.RegisterValueChangedCallback((x) => Bookmarks.Instance[index].shortcut = (KeyCode)x.newValue);
                bookmarkElement.Add(shortcutMask);

                Button moveUpButton = new Button(() =>
                {
                    if (index <= 0)
                    {
                        return;
                    }

                    var item = Bookmarks.Instance.viewpoints[index];
                    Bookmarks.Instance.viewpoints.RemoveAt(index);

                    Bookmarks.Instance.viewpoints.Insert(index - 1, item);
                    RefreshUI();
                })
                {
                    name = "Up", text = "Up"
                };
                moveUpButton.AddToClassList("svbm-cell-button");
                bookmarkElement.Add(moveUpButton);

                Button moveDownButton = new Button(() =>
                {
                    if (index >= Bookmarks.Instance.viewpoints.Count - 1)
                    {
                        return;
                    }

                    var item = Bookmarks.Instance.viewpoints[index];
                    Bookmarks.Instance.viewpoints.RemoveAt(index);

                    Bookmarks.Instance.viewpoints.Insert(index + 1, item);
                    RefreshUI();
                })
                {
                    name = "Down", text = "Dn"
                };
                moveDownButton.AddToClassList("svbm-cell-button");
                bookmarkElement.Add(moveDownButton);

                rootVisualElement.Add(bookmarkElement);
            }
        }
        public override VisualElement CreateInspectorGUI()
        {
            if (Selection.activeObject is null || Selection.objects.Length == 0)
            {
                return(base.CreateInspectorGUI());
            }
            if (!GetType().IsSubclassOf(typeof(ScriptableObject)) || categoryList is null || categoryList.Count == 0)
            {
                return(base.CreateInspectorGUI());
            }
            if (!idConfig.AAIConfiguration().enableCustomEditors)
            {
                return(base.CreateInspectorGUI());
            }

            var baseStyleSheet = idConfig.GetStyleSheet("AAIDefaultEditorBase");

            if (defaultStyleSheet is null)
            {
                defaultStyleSheet = idConfig.GetStyleSheet("AAIDefaultEditorStyle");
            }
            if (defaultStyleSheet is null)
            {
                Debug.Log("Could not locate AAIDefaultEditorStyle");
            }

            serializedObject.Update();

            defaultRoot = new VisualElement();

            defaultRoot.styleSheets.Add(baseStyleSheet);
            defaultRoot.styleSheets.Add(defaultStyleSheet);
            defaultRoot.AddToClassList("rootContainer");

            var boxContainer = new Box();

            boxContainer.AddToClassList("mainBoxContainer");

            if (beforeDefaultElements == null)
            {
                beforeDefaultElements = new VisualElement();
            }
            beforeDefaultElements.name = "beforeDefaultElements";
            beforeDefaultElements.AddToClassList("beforeDefaultElements");
            defaultRoot.Add(beforeDefaultElements);

            categoryList.ForEach(x =>
            {
                if (x is null)
                {
                    return;
                }
                x.AddToClassList("categoryFoldout");
                boxContainer.Add(x);
            });

            m_ScrollView = new ScrollView();
            boxContainer.Add(m_ScrollView);

            keyData = classDataDictionary.Keys.ToList();

            #region Property Iteration

            var property = serializedObject.GetIterator();
            if (property.NextVisible(true))
            {
                do
                {
                    // -- Shortening name for ease of typing -------------
                    var propPath = property.propertyPath;

                    // -- Skip over excluded fields ----------------------
                    if (excludedFields.Contains(propPath) && serializedObject.targetObject != null)
                    {
                        continue;
                    }

                    // -- Property row VisualElement ---------------------
                    var propertyRow    = new VisualElement();
                    var propertyColumn = new VisualElement();
                    propertyRow.AddToClassList("propertyRow");
                    propertyColumn.AddToClassList("propertyColumn");

                    // -- Property fallback field ------------------------
                    var propertyField = new PropertyField(property)
                    {
                        name = "PropertyField:" + propPath
                    };

                    // -- Determine if current property is field data ----
                    if (!classDataDictionary[Enumerable.First(keyData)].fieldDatas.Keys.Contains(propPath))
                    {
                        switch (propPath)
                        {
                        case "m_Script" when serializedObject.targetObject != null:
                            propertyField.visible = false;     // @formatter:off
                            propertyField.SetEnabled(false);
                            break;

                        default:
                            if (property.IsReallyArray() && serializedObject.targetObject != null)
                            {
                                var copiedProperty    = property.Copy();
                                var imDefaultProperty = new IMGUIContainer(() =>
                                {
                                    DoDrawDefaultIMGUIProperty(serializedObject, copiedProperty);
                                })
                                {
                                    name = propPath
                                };
                                m_ScrollView.Add(imDefaultProperty);
                            }
                            break;     // @formatter:on
                        }
                    }
                    else
                    {
                        var propertyData = classDataDictionary[Enumerable.First(keyData)].fieldDatas[propPath];
                        switch (propertyData.fieldInfo)
                        {
                        // -- String/TextField Elements --------------
                        case FieldInfo a when a.FieldType == typeof(string):
                        case FieldInfo b when b.FieldType == typeof(PropertyName):
                            if (defaultEditorDebug)
                            {
                                Debug.Log($"String: {propPath}");
                            }

                            var propertyTextLabel = new Label(property.displayName);
                            propertyTextLabel.name = $"{propPath}Label";
                            var propertyTextField = new TextField
                            {
                                bindingPath = propPath,
                                name        = $"{propPath}Text"
                            };

                            if (propertyData.categoryAttr.toolTip != "")
                            {
                                propertyTextLabel.tooltip = propertyData.categoryAttr.toolTip;
                                propertyTextField.tooltip = propertyData.categoryAttr.toolTip;
                            }

                            propertyTextLabel.AddToClassList("propertyTextLabel");
                            propertyTextField.AddToClassList("propertyTextField");
                            propertyRow.Add(propertyTextLabel);
                            propertyRow.Add(propertyTextField);
                            boxContainer.Q(propertyData.categoryAttr.category).Add(propertyRow);
                            break;

                        // -- Integer Elements -----------------------
                        case FieldInfo a when a.FieldType == typeof(int):
                            if (defaultEditorDebug)
                            {
                                Debug.Log($"Integer: {propPath}");
                            }
                            var propertyIntegerLabel = new Label(property.displayName);
                            propertyIntegerLabel.name = $"{propPath}Label";
                            var propertyIntegerField = new IntegerField
                            {
                                bindingPath = propPath,
                                name        = $"{propPath}Integer"
                            };

                            if (propertyData.categoryAttr.toolTip != "")
                            {
                                propertyIntegerLabel.tooltip = propertyData.categoryAttr.toolTip;
                                propertyIntegerField.tooltip = propertyData.categoryAttr.toolTip;
                            }

                            propertyIntegerLabel.AddToClassList("propertyIntegerLabel");
                            propertyIntegerField.AddToClassList("propertyIntegerField");
                            propertyRow.Add(propertyIntegerLabel);
                            propertyRow.Add(propertyIntegerField);
                            boxContainer.Q(propertyData.categoryAttr.category).Add(propertyRow);
                            break;

                        // -- Float Elements -------------------------
                        case FieldInfo a when a.FieldType == typeof(float):
                            if (defaultEditorDebug)
                            {
                                Debug.Log($"Float: {propPath}");
                            }

                            var propertyFloatLabel = new Label(property.displayName);
                            propertyFloatLabel.name = $"{propPath}Label";
                            var propertyFloatField = new FloatField
                            {
                                bindingPath = propPath,
                                name        = $"{propPath}Float"
                            };

                            if (propertyData.categoryAttr.toolTip != "")
                            {
                                propertyFloatLabel.tooltip = propertyData.categoryAttr.toolTip;
                                propertyFloatField.tooltip = propertyData.categoryAttr.toolTip;
                            }

                            propertyFloatLabel.AddToClassList("propertyFloatLabel");
                            propertyFloatField.AddToClassList("propertyFloatField");
                            propertyRow.Add(propertyFloatLabel);
                            propertyRow.Add(propertyFloatField);
                            boxContainer.Q(propertyData.categoryAttr.category).Add(propertyRow);
                            break;

                        // -- Bool/Toggle Elements -------------------
                        case FieldInfo a when a.FieldType == typeof(bool):
                        case FieldInfo b when b.FieldType == typeof(Toggle):
                            if (defaultEditorDebug)
                            {
                                Debug.Log($"Toggle: {propPath}");
                            }

                            var propertyToggleLabel = new Label(property.displayName);
                            propertyToggleLabel.name = $"{propPath}ToggleLabel";
                            var propertyToggleSpacer = new VisualElement();
                            var propertyToggleField  = new Toggle
                            {
                                bindingPath = propPath,
                                name        = $"{propPath}ToggleField"
                            };

                            if (propertyData.categoryAttr.toolTip != "")
                            {
                                propertyToggleLabel.tooltip = propertyData.categoryAttr.toolTip;
                                propertyToggleField.tooltip = propertyData.categoryAttr.toolTip;
                            }


                            propertyToggleLabel.AddToClassList("propertyToggleLabel");
                            propertyToggleLabel.AddToClassList("propertyToggleSpacer");
                            propertyToggleField.AddToClassList("propertyToggleField");
                            propertyRow.Add(propertyToggleLabel);
                            propertyRow.Add(propertyToggleField);
                            propertyRow.Add(propertyToggleSpacer);
                            propertyRow.RemoveFromClassList("propertyRow");
                            propertyRow.AddToClassList("propertyToggleRow");
                            boxContainer.Q(propertyData.categoryAttr.category).Add(propertyRow);
                            break;

                        // -- Dictionary Elements --------------------
                        case FieldInfo a when typeof(IDictionary).IsAssignableFrom(a.FieldType):
                        case FieldInfo b when typeof(IDictionary).IsSubclassOf(b.FieldType):
                            var dictionaryFoldout = new Foldout {
                                text = property.displayName
                            };
                            dictionaryFoldout.AddToClassList("arrayFoldout");
                            dictionaryFoldout.value = false;

                            if (propertyData.categoryAttr.toolTip != "")
                            {
                                dictionaryFoldout.tooltip = propertyData.categoryAttr.toolTip;
                                propertyColumn.tooltip    = propertyData.categoryAttr.toolTip;
                            }

                            dictionaryFoldout.Add(propertyField);
                            propertyColumn.Add(dictionaryFoldout);
                            boxContainer.Q(propertyData.categoryAttr.category).Add(propertyColumn);
                            break;

                        // -- List/Set Elements ----------------------
                        case FieldInfo a when typeof(IList).IsAssignableFrom(a.FieldType):
                        case FieldInfo b when typeof(IList).IsSubclassOf(b.FieldType):
                        case FieldInfo c when typeof(ISet <>).IsAssignableFrom(c.FieldType):
                        case FieldInfo d when typeof(ISet <>).IsSubclassOf(d.FieldType):
                            var arrayElementBuilder = new ArrayElementBuilder(property, propertyData);

                            if (propertyData.categoryAttr.toolTip != "")
                            {
                                propertyRow.tooltip = propertyData.categoryAttr.toolTip;
                            }

                            propertyRow.Add(arrayElementBuilder);
                            boxContainer.Q(propertyData.categoryAttr.category).Add(propertyRow);
                            break;

                        // -- Object Elements ----------------------
                        case FieldInfo a when a.FieldType == typeof(Object):
                        case FieldInfo b when typeof(Object).IsSubclassOf(b.FieldType):
                        case FieldInfo c when typeof(Object).IsAssignableFrom(c.FieldType):
                            var propertyObjectLabel = new Label(property.displayName);
                            propertyObjectLabel.name = $"{propPath}ObjectLabel";
                            var propertyObjectField = new ObjectField
                            {
                                objectType  = propertyData.fieldType,
                                bindingPath = propPath,
                                name        = $"{propPath}ObjectField"
                            };

                            if (propertyData.categoryAttr.toolTip != "")
                            {
                                propertyObjectLabel.tooltip = propertyData.categoryAttr.toolTip;
                                propertyObjectField.tooltip = propertyData.categoryAttr.toolTip;
                            }

                            propertyObjectLabel.AddToClassList("propertyObjectLabel");
                            propertyObjectField.AddToClassList("propertyObjectField");
                            propertyRow.Add(propertyObjectLabel);
                            propertyRow.Add(propertyObjectField);
                            boxContainer.Q(propertyData.categoryAttr.category).Add(propertyRow);
                            if (defaultEditorDebug)
                            {
                                Debug.Log($"Fallback Test: Name: {propPath} Type: {property.type} Array: {property.isArray} : {property.propertyType}");
                            }
                            break;

                        default:
                            if (property.IsReallyArray())
                            {
                                propertyColumn.Add(propertyField);
                                boxContainer.Q(propertyData.categoryAttr.category).Add(propertyColumn);
                            }

                            // else propertyColumn.Add(propertyField);
                            //
                            if (propertyData.categoryAttr.toolTip != "")
                            {
                                propertyColumn.tooltip = propertyData.categoryAttr.toolTip;
                            }

                            //
                            // boxContainer.Q(propertyData.categoryAttr.category).Add(propertyColumn);
                            break;
                        }
                    }
                } while (property.NextVisible(false));
            }

            #endregion

            foreach (var foldoutList in m_ScrollView.Query <Foldout>().ToList())
            {
                foldoutList.RegisterValueChangedCallback(e =>
                {
                    // TODO Remove this:
                    if (!(e.target is Foldout fd))
                    {
                        return;
                    }
                    Debug.Log($" {fd.name}");
                    var path      = fd.bindingPath;
                    var container = m_ScrollView.Q <IMGUIContainer>(path);
                    RecomputeSize(container);
                });
            }

            foreach (var foldoutList in m_ScrollView.Query <AnimatedFoldout>().ToList())
            {
                foldoutList.RegisterValueChangedCallback(e =>
                {
                    // TODO Remove this:
                    if (!(e.target is Foldout fd))
                    {
                        return;
                    }
                    Debug.Log($" {fd.name}");
                    var path      = fd.bindingPath;
                    var container = m_ScrollView.Q <IMGUIContainer>(path);
                    RecomputeSize(container);
                });
            }

            VisualElement defaultCategory = null;
            for (var i = 0; i < categoryList.Count; i++)
            {
                VisualElement x;
                if (isAnimated)
                {
                    x = categoryList[i].Q <AnimatedFoldout>();
                }
                else
                {
                    x = categoryList[i].Q <Foldout>();
                }
                if (x.name != "Default")
                {
                    continue;
                }
                defaultCategory = x;
                break;
            }

            if (defaultCategory.childCount == 0)
            {
                defaultCategory.style.display = DisplayStyle.None;
            }

            if (isAnimated)
            {
                var listItems = boxContainer.Query <AnimatedFoldout>().ToList();
                listItems.ForEach(x => foldout.Add((AnimatedFoldout)x));
            }
            else
            {
                var listItems = boxContainer.Query <Foldout>().ToList();
                listItems.ForEach(x => foldout.Add((Foldout)x));
            }

            foldout.ForEach(x =>
            {
                Toggle toggleItem;
                if (isAnimated)
                {
                    var item        = (AnimatedFoldout)x;
                    var contentItem = item.Q(null, AnimatedFoldout.expanderUssClassName);
                    contentItem.ToggleInClassList("categoryFoldoutClosed");
                    item.Q(null, "unity-toggle__checkmark").AddToClassList("toggleCheckmark");
                    item.RegisterCallback((ChangeEvent <bool> evt) =>
                    {
                        var targetElement = evt.target as VisualElement;

                        if (targetElement == item)
                        {
                            item.value = evt.newValue;
                        }

                        if (targetElement.parent == item || targetElement == item || targetElement.contentContainer == item)
                        {
                            item.value = evt.newValue;
                            // if (evt.newValue) item.contentContainer.style.display = DisplayStyle.Flex;

                            // if (!evt.newValue) // @formatter:off
                            // {
                            //     item.schedule.Execute(() =>
                            //     {
                            //         item.contentContainer.style.display = DisplayStyle.None;
                            //     }).StartingIn(500);
                            //     item.schedule.Execute(() =>
                            //     {
                            //         contentItem.style.display = DisplayStyle.None;
                            //     }).StartingIn(600); // @formatter:on
                            // }
                        }
                        else
                        {
                            item.expander.TriggerExpanderResize(true);
                        }
                    }); // @formatter:on
                }
                else
                {
                    var item   = (Foldout)x;
                    toggleItem = item.Q <Toggle>();
                    toggleItem.ToggleInClassList("categoryFoldoutClosed");
                    item.Q(null, "unity-toggle__checkmark").AddToClassList("toggleCheckmark");
                }
            });

            serializedObject.ApplyModifiedProperties();

            if (afterDefaultElements == null)
            {
                afterDefaultElements = new VisualElement();
            }
            afterDefaultElements.name = "afterDefaultElements";
            afterDefaultElements.AddToClassList("afterDefaultElements");

            boxContainer.Add(afterDefaultElements);
            defaultRoot.Add(boxContainer);

            defaultRoot.RegisterCallback <GeometryChangedEvent>(ExecutePostBuildTask);
            defaultRoot.schedule.Execute(ExecuteLocalDeferredTask).StartingIn(0);

            return(defaultRoot);
        }