Exemple #1
0
        public override VisualElement Build()
        {
            var valueField = new Vector4Field {
                bindingPath = "Value"
            };

            valueField.Query <FloatField>().ForEach(field => field.formatString = "0.###");
            return(valueField);
        }
Exemple #2
0
        public override VisualElement Build()
        {
            var root = new BindableElement
            {
                bindingPath = "Value"
            };

            for (var i = 0; i < 4; ++i)
            {
                var column = new Vector4Field {
                    bindingPath = "c" + i
                };
                column.Query <FloatField>().ForEach(field => field.formatString = "0.###");
                root.Add(column);
            }

            return(root);
        }
Exemple #3
0
        internal VisualElement CreateGUI(
            ValueChangedCallback valueChangedCallback,
            Vector4 fieldToDraw,
            string labelName,
            out VisualElement propertyVec4Field,
            int indentLevel = 0)
        {
            var vector4Field = new Vector4Field {
                value = fieldToDraw
            };

            var inputFields = vector4Field.Query("unity-text-input").ToList();

            foreach (var inputField in inputFields)
            {
                inputField.RegisterCallback <KeyDownEvent>(m_KeyDownCallback);
                inputField.RegisterCallback <FocusOutEvent>(m_FocusOutCallback);
            }

            vector4Field.RegisterValueChangedCallback(evt =>
            {
                // Only true when setting value via FieldMouseDragger
                // Undo recorded once per dragger release
                if (mUndoGroup == -1)
                {
                    preValueChangeCallback?.Invoke();
                }

                valueChangedCallback(evt.newValue);
                postValueChangeCallback?.Invoke();
            });

            propertyVec4Field = vector4Field;

            var defaultRow = new PropertyRow(PropertyDrawerUtils.CreateLabel(labelName, indentLevel));

            defaultRow.Add(propertyVec4Field);
            defaultRow.styleSheets.Add(Resources.Load <StyleSheet>("Styles/PropertyRow"));
            return(defaultRow);
        }