public void Refresh()
        {
            // HACK until fix goes in:
            m_CanvasWidth.isDelayed  = false;
            m_CanvasHeight.isDelayed = false;

            m_CanvasWidth.SetValueWithoutNotify(settings.CanvasWidth);
            m_CanvasHeight.SetValueWithoutNotify(settings.CanvasHeight);

            m_CanvasWidth.isDelayed  = true;
            m_CanvasHeight.isDelayed = true;

            m_OpacityField.SetValueWithoutNotify(settings.CanvasBackgroundOpacity);
            m_BackgroundMode.SetValueWithoutNotify(settings.CanvasBackgroundMode.ToString());

            m_ColorField.SetValueWithoutNotify(settings.CanvasBackgroundColor);

            var scaleModeStr = settings.CanvasBackgroundImageScaleMode.ToString();

            scaleModeStr = BuilderNameUtilities.ConvertCamelToDash(scaleModeStr);
            m_ImageField.SetValueWithoutNotify(settings.CanvasBackgroundImage);
            m_ImageScaleModeField.SetValueWithoutNotify(scaleModeStr);

            m_CameraField.SetValueWithoutNotify(FindCameraByName());

            ApplyBackgroundOptions();
        }
        public void Refresh()
        {
            // HACK until fix goes in:
            SetDelayOnSizeFieldsEnabled(false);

            m_CanvasWidth.SetValueWithoutNotify(settings.CanvasWidth);
            m_CanvasHeight.SetValueWithoutNotify(settings.CanvasHeight);

            SetDelayOnSizeFieldsEnabled(true);

            m_BackgroundOptionsFoldout.SetCheckboxValueWithoutNotify(settings.EnableCanvasBackground);

            m_ColorOpacityField.SetValueWithoutNotify(settings.ColorModeBackgroundOpacity);
            m_ImageOpacityField.SetValueWithoutNotify(settings.ImageModeCanvasBackgroundOpacity);
            m_CameraOpacityField.SetValueWithoutNotify(settings.CameraModeCanvasBackgroundOpacity);

            m_BackgroundMode.SetValueWithoutNotify(settings.CanvasBackgroundMode.ToString());
            m_ColorField.SetValueWithoutNotify(settings.CanvasBackgroundColor);

            var scaleModeStr = settings.CanvasBackgroundImageScaleMode.ToString();

            scaleModeStr = BuilderNameUtilities.ConvertCamelToDash(scaleModeStr);
            m_ImageField.SetValueWithoutNotify(settings.CanvasBackgroundImage);
            m_ImageScaleModeField.SetValueWithoutNotify(scaleModeStr);

            m_CameraField.SetValueWithoutNotify(FindCameraByName());
            m_EditorExtensionsModeToggle?.SetValueWithoutNotify(m_Document.fileSettings.editorExtensionMode);

            ApplyBackgroundOptions();
            RefreshMatchGameViewToggle();
        }
 private void UpdatePositionField(Rect rect)
 {
     m_PositionFieldX.SetValueWithoutNotify((int)selectedSpriteRect.x);
     m_PositionFieldY.SetValueWithoutNotify((int)selectedSpriteRect.y);
     m_PositionFieldW.SetValueWithoutNotify((int)selectedSpriteRect.width);
     m_PositionFieldH.SetValueWithoutNotify((int)selectedSpriteRect.height);
 }
            private void InitStyleValues()
            {
                if (m_SelectedElement != null)
                {
                    switch (boxType)
                    {
                    case BoxType.Margin:
                        InitOnMargins();
                        break;

                    case BoxType.Border:
                        InitOnBorders();
                        break;

                    case BoxType.Padding:
                        InitOnPaddings();
                        break;
                    }
                }
                else
                {
                    m_LeftTextField.SetValueWithoutNotify(0);
                    m_RightTextField.SetValueWithoutNotify(0);
                    m_TopTextField.SetValueWithoutNotify(0);
                    m_BottomTextField.SetValueWithoutNotify(0);
                }
            }
        public override void Reload(IProperty property)
        {
            m_ContentRoot.Clear();

            var list = GetValue();

            if (null == list)
            {
                return;
            }

            m_PaginationElement.Update(list.Count);

            if (m_Size.focusController?.focusedElement != m_Size)
            {
                m_Size.isDelayed = false;
                m_Size.SetValueWithoutNotify(list.Count);
                m_Size.isDelayed = true;
            }

            var startIndex = 0;
            var endIndex   = list.Count;

            if (UsesPagination)
            {
                startIndex = m_PaginationElement.StartIndex;
                endIndex   = m_PaginationElement.EndIndex;
            }

            var atIndexPath = PropertyPath.Pool.Get();

            try
            {
                atIndexPath.PushPath(Path);

                for (var i = startIndex; i < endIndex; ++i)
                {
                    var index = i;

                    atIndexPath.PushIndex(index);
                    try
                    {
                        var root = new VisualElement();
                        Root.VisitAtPath(atIndexPath, root);
                        MakeListElement(root, index);
                        m_ContentRoot.Add(root);
                    }
                    finally
                    {
                        atIndexPath.Pop();
                    }
                }
            }
            finally
            {
                PropertyPath.Pool.Release(atIndexPath);
            }
        }
Example #6
0
        public static VisualElement GetElementOfIntField(int startValue, string fieldName, Action <object> setValue, Action <object> getValue)
        {
            IntegerField field = new IntegerField(fieldName);

            field.SetValueWithoutNotify(startValue);
            field.RegisterValueChangedCallback(s => setValue.Invoke(s.newValue));
            getValue += o => field.SetValueWithoutNotify((int)o);
            return(field);
        }
Example #7
0
 private void UpdateBorderField(FocusOutEvent evt)
 {
     if (hasSelected)
     {
         m_BorderFieldL.SetValueWithoutNotify((int)selectedSpriteBorder.x);
         m_BorderFieldB.SetValueWithoutNotify((int)selectedSpriteBorder.y);
         m_BorderFieldR.SetValueWithoutNotify((int)selectedSpriteBorder.z);
         m_BorderFieldT.SetValueWithoutNotify((int)selectedSpriteBorder.w);
     }
 }
Example #8
0
 protected void UpdatePositionField(FocusOutEvent evt)
 {
     if (hasSelected)
     {
         m_PositionFieldX.SetValueWithoutNotify((int)selectedSpriteRect.x);
         m_PositionFieldY.SetValueWithoutNotify((int)selectedSpriteRect.y);
         m_PositionFieldW.SetValueWithoutNotify((int)selectedSpriteRect.width);
         m_PositionFieldH.SetValueWithoutNotify((int)selectedSpriteRect.height);
     }
 }
Example #9
0
        public override void UpdateFromChildFields()
        {
            var styleFields = this.Query <StyleFieldBase>().ToList();

            bool   allTheSame      = true;
            string singleValue     = string.Empty;
            string cumulativeValue = string.Empty;

            for (int i = 0; i < styleFields.Count; ++i)
            {
                if (i == 0)
                {
                    singleValue = styleFields[i].value;
                }
                else if (singleValue != styleFields[i].value)
                {
                    allTheSame = false;
                }

                if (i != 0)
                {
                    cumulativeValue += k_FieldStringSeparator;
                }

                cumulativeValue += styleFields[i].value;
            }

            if (allTheSame)
            {
                m_TextField.SetValueWithoutNotify(singleValue);
            }
            else
            {
                m_TextField.SetValueWithoutNotify(cumulativeValue);
            }

            if (styleFields.Count > 0 && (styleFields[0] is StyleField <int> || styleFields[0] is StyleField <float>))
            {
                var intField   = styleFields[0] as StyleField <int>;
                var floatField = styleFields[0] as StyleField <float>;

                if (intField != null)
                {
                    m_DraggerIntegerField.SetValueWithoutNotify(intField.innerValue);
                }
                else
                {
                    m_DraggerIntegerField.SetValueWithoutNotify((int)floatField.innerValue);
                }
            }
        }
Example #10
0
            public void SelectElement(VisualElement ve)
            {
                m_SelectedElement = ve;

                if (ve != null)
                {
                    m_WidthTextField.SetValueWithoutNotify((int)m_SelectedElement.contentRect.width);
                    m_HeightTextField.SetValueWithoutNotify((int)m_SelectedElement.contentRect.height);
                }
                else
                {
                    m_WidthTextField.SetValueWithoutNotify(0);
                    m_HeightTextField.SetValueWithoutNotify(0);
                }
            }
Example #11
0
        public void Bind(TransitionInfoCondition condition)
        {
            _condition = condition;

            if (_parameterFinder.Item != null)
            {
                _parameterFinder.Item.OnTypeChanged -= ParameterTypeChanged;
            }

            _parameterFinder.SelectItemWithoutNotify(_condition.Parameter, true);

            if (_parameterFinder.Item != null)
            {
                _parameterFinder.Item.OnTypeChanged += ParameterTypeChanged;
            }

            _stateFinder.SelectItemWithoutNotify(_condition.State, true);
            _stateValueProvider.SetValueWithoutNotify(_condition.StateValueProvider);

            SetProviderSourceType(_condition.ProviderSourceType);

            _boolComparisonValueField.SetValueWithoutNotify(_condition.BoolComparisonValue ? Bool.True : Bool.False);

            _intComparisonField.SetValueWithoutNotify(_condition.IntComparison);
            _intComparisonValueField.SetValueWithoutNotify(_condition.IntComparisonValue);

            _floatComparisonField.SetValueWithoutNotify(_condition.FloatComparison);
            _floatComparisonValueField.SetValueWithoutNotify(_condition.FloatComparisonValue);
        }
 static void ClampEditingValue(ChangeEvent <int> evt, IntegerField field)
 {
     if (evt.newValue < 0)
     {
         field.SetValueWithoutNotify(0);
     }
 }
        protected override void DrawNode(ModuleGraphView graphView)
        {
            Debug.Log(Script.SceneIndex);
            var inputPort = graphView.GeneratePort <float>(this, Direction.Input, Port.Capacity.Multi);

            inputPort.portName = "Input";
            inputContainer.Add(inputPort);
            AddToClassList("action");

            var outputPort = graphView.GeneratePort <float>(this, Direction.Output);

            outputPort.portName = "Output";
            outputContainer.Add(outputPort);

            IntegerField intField = new IntegerField("Scene Index", 2);

            intField.value = Script.SceneIndex;
            intField.RegisterValueChangedCallback(evt =>
            {
                var temp = evt.newValue < 0 ? 0 : evt.newValue > 99 ? 99 : evt.newValue;
                intField.SetValueWithoutNotify(temp);
                Script.SceneIndex = temp;
                graphView.SetDirty();
            });

            extensionContainer.Add(intField);

            graphView.RefreshNode(this);
            graphView.AddElement(this);
        }
Example #14
0
        public static IntegerField CollectionSizeField <TProperty, TContainer, TValue>(
            TProperty property,
            ref TContainer container,
            ref TValue value,
            InspectorVisitorContext visitorContext)
            where TProperty : ICollectionProperty <TContainer, TValue>
        {
            var field = new IntegerField
            {
                name        = "CollectionSize",
                label       = "Size",
                bindingPath = string.Empty,
                isDelayed   = true
            };

            field.SetValueWithoutNotify(property.GetCount(ref container));
            SetTooltip(property.Attributes, field);
            var parent = visitorContext.Parent;

            visitorContext.Parent.contentContainer.Add(field);
            field.RegisterValueChangedCallback(evt =>
            {
                visitorContext.Binding.SetCount(parent, Mathf.Clamp(evt.newValue, 0, int.MaxValue));
            });
            return(field);
        }
        protected void PopulateSpriteFrameInspectorField()
        {
            m_SelectedFrameInspector.style.display = hasSelected ?  DisplayStyle.Flex : DisplayStyle.None;
            if (!hasSelected)
            {
                return;
            }
            m_NameElement.SetEnabled(containsMultipleSprites);
            m_NameField.SetValueWithoutNotify(selectedSpriteName);
            m_PositionElement.SetEnabled(containsMultipleSprites);
            var spriteRect = selectedSpriteRect;

            m_PositionFieldX.SetValueWithoutNotify(Mathf.RoundToInt(spriteRect.x));
            m_PositionFieldY.SetValueWithoutNotify(Mathf.RoundToInt(spriteRect.y));
            m_PositionFieldW.SetValueWithoutNotify(Mathf.RoundToInt(spriteRect.width));
            m_PositionFieldH.SetValueWithoutNotify(Mathf.RoundToInt(spriteRect.height));
            var spriteBorder = selectedSpriteBorder;

            m_BorderFieldL.SetValueWithoutNotify(Mathf.RoundToInt(spriteBorder.x));
            m_BorderFieldT.SetValueWithoutNotify(Mathf.RoundToInt(spriteBorder.w));
            m_BorderFieldR.SetValueWithoutNotify(Mathf.RoundToInt(spriteBorder.z));
            m_BorderFieldB.SetValueWithoutNotify(Mathf.RoundToInt(spriteBorder.y));
            m_PivotField.SetValueWithoutNotify(selectedSpriteAlignment);
            m_PivotUnitModeField.SetValueWithoutNotify(m_PivotUnitMode);
            Vector2 pivot = selectedSpritePivotInCurUnitMode;

            m_CustomPivotFieldX.SetValueWithoutNotify(pivot.x);
            m_CustomPivotFieldY.SetValueWithoutNotify(pivot.y);

            m_CustomPivotElement.SetEnabled(hasSelected && selectedSpriteAlignment == SpriteAlignment.Custom);
        }
        public void LoadData(Parameter parameter)
        {
            Name = parameter.Name;

            ParameterTypeField.SetValueWithoutNotify(parameter.Type);
            ChangeParameterType(parameter.Type, default);

            switch (parameter.ValueProvider)
            {
            case BoolProvider boolProvider:
                BoolField.SetValueWithoutNotify(boolProvider.Value);
                break;

            case IntProvider intProvider:
                IntField.SetValueWithoutNotify(intProvider.Value);
                break;

            case FloatProvider floatProvider:
                FloatField.SetValueWithoutNotify(floatProvider.Value);
                break;

            default:
                break;
            }
        }
        public void Update(InspectorDataProxy <LayerSorting> proxy)
        {
            var data  = proxy.Data;
            var index = m_Names.FindIndex(l => l.id == data.id);

            m_Layers.index = index < 0 ? 0 : index;
            m_Order.SetValueWithoutNotify(data.order);
        }
Example #18
0
 public static void SetCollectionSize(IntegerField element, int size)
 {
     if (element?.focusController?.focusedElement != element)
     {
         element.isDelayed = false;
         element.SetValueWithoutNotify(size);
         element.isDelayed = true;
     }
 }
        protected void BindBaseCreateElements(Button cancelButton, Button createButton, TextField nameField, IntegerField countField, Toggle maxCountToggle)
        {
            cancelButton.clickable.clicked += OnCancelClicked;
            createButton.clickable.clicked += OnCreateClicked;

            if (GetDefaultName != null)
            {
                m_CurrentName = GetDefaultName();
            }

            m_NameField           = nameField;
            m_NameField.isDelayed = true;
            m_NameField.SetValueWithoutNotify(m_CurrentName);
            m_NameIsCustom = false;
            m_NameField.RegisterValueChangedCallback(evt =>
            {
                if (evt.newValue.Length > 0)
                {
                    m_CurrentName  = evt.newValue;
                    m_NameIsCustom = true;
                }
                else if (GetDefaultName != null)
                {
                    m_CurrentName = GetDefaultName();
                    m_NameField?.SetValueWithoutNotify(m_CurrentName);
                    m_NameIsCustom = false;
                }

                if (NameChanged != null)
                {
                    NameChanged(m_CurrentName);
                }
            });

            maxCountToggle.RegisterValueChangedCallback(evt =>
            {
                m_CountField.value = evt.newValue ? 1 : 0;
                m_CountField.SetEnabled(evt.newValue);
            });

            m_CountField = countField;
            m_CountField.RegisterValueChangedCallback(evt =>
            {
                var newValue = evt.newValue;
                if (newValue < 0)
                {
                    newValue = 0;
                    m_CountField.SetValueWithoutNotify(newValue);
                }

                var maxEnabled = newValue > 0;
                maxCountToggle.SetValueWithoutNotify(maxEnabled);
                m_CountField.SetEnabled(maxEnabled);

                CountChanged?.Invoke(newValue);
            });
        }
Example #20
0
        void SetDragFieldLimit(IntegerField field, int value)
        {
            // The only way to know if value change is due to dragger or text input
            var t = field.Q("unity-text-input");

            if (!t.focusController.IsFocused(t))
            {
                // Value changed due to drag. We set back the field so to show the drag limit
                field.SetValueWithoutNotify(value);
            }
        }
        void RefreshSubFields()
        {
            var intNewValue = (int)(value * 100);

            mSlider.SetValueWithoutNotify(intNewValue);
            if (mSlider.elementPanel != null)
            {
                mSlider.OnViewDataReady(); // Hack to force update the slide handle position.
            }
            mField.SetValueWithoutNotify(intNewValue);
        }
        public static void RenderIntProperty(
            VisualElement container,
            string name,
            object value,
            Action <object> setter)
        {
            var field = new IntegerField(name);

            field.SetValueWithoutNotify((int)value);
            field.MarkDirtyRepaint();
            field.RegisterValueChangedCallback(evt => setter(evt.newValue));
            container.Add(field);
        }
    private void AddNewTableEntry(Button pressedButton, SpeakEasyNode node, IntegerField indexField, TextField textField)
    {
        //Check if we by any chance already have a reference.
        for (int i = 0; i < localText.localizedText.Count; i++)
        {
            if (node.stringReference == "" || node.stringReference == System.String.Empty)
            {
                EditorUtility.DisplayDialog("Oops!", "Sorry, cannot add a new entry without a proper Identifier.", "OK");
                return;
            }

            if (node.stringReference == localText.localizedText[i].id)
            {
                //We already have a point of reference
                pressedButton.SetEnabled(false);
                node.stringIndex = i;
                indexField.SetValueWithoutNotify(node.stringIndex);
                textField.SetValueWithoutNotify(GetStringIndex(node.stringIndex));
                textField.SetEnabled(true);

                return;
            }
        }

        pressedButton.SetEnabled(false); //We no longer need a new reference point.

        //Give this node a new string ID
        node.stringIndex = localText.localizedText.Count; //the Count is always +1 which means it will place the new reference at the right index.. right?
        localText.localizedText.Add(new LocalizedText()
        {
            id = node.stringReference
        });                                                                           //we add the new address for the list.

        //Now we need to connect the three fields
        indexField.SetValueWithoutNotify(node.stringIndex);
        textField.SetValueWithoutNotify(GetStringIndex(node.stringIndex));
        textField.SetEnabled(true);
    }
Example #24
0
        // Start is called before the first frame update
        void OnEnable()
        {
            this.name = "ShaderStrippingConfig";
            var tree = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>("Packages/com.utj.stripvariant/Editor/UXML/ConfigUI.uxml");

            this.rootVisualElement.Add(tree.CloneTree());

            enableToggle      = this.rootVisualElement.Q <Toggle>("Enabled");
            logToggle         = this.rootVisualElement.Q <Toggle>("LogEnable");
            strictModeToggle  = this.rootVisualElement.Q <Toggle>("StrictVariantStripping");
            disableUnityStrip = this.rootVisualElement.Q <Toggle>("DisableUnityStrip");

            orderIntField      = this.rootVisualElement.Q <IntegerField>("ExecuteOrder");
            executeOrderMinBtn = this.rootVisualElement.Q <Button>("ExecOrderMinBtn");
            executeOrderMaxBtn = this.rootVisualElement.Q <Button>("ExecOrderMaxBtn");

            resetTimestampBtn = this.rootVisualElement.Q <Button>("ResetTimestampBtn");

            addExcludeBtn          = this.rootVisualElement.Q <Button>("AppendExcludeBtn");
            excludeVariantListView = this.rootVisualElement.Q <ListView>("ExcludeList");

            debugListViewBtn = this.rootVisualElement.Q <Button>("DebugListProcessorBtn");


            enableToggle.SetValueWithoutNotify(StripShaderConfig.IsEnable);
            logToggle.SetValueWithoutNotify(StripShaderConfig.IsLogEnable);
            strictModeToggle.SetValueWithoutNotify(StripShaderConfig.StrictVariantStripping);
            disableUnityStrip.SetValueWithoutNotify(StripShaderConfig.DisableUnityStrip);
            orderIntField.SetValueWithoutNotify(StripShaderConfig.Order);

            enableToggle.RegisterValueChangedCallback(OnChangeEnabbleToggle);
            logToggle.RegisterValueChangedCallback(OnChangeLogEnabbleToggle);
            strictModeToggle.RegisterValueChangedCallback(OnChangeStrictModeToggle);
            disableUnityStrip.RegisterValueChangedCallback(OnChangeDisableUnityStripToggle);

            resetTimestampBtn.clicked += OnClickResetTimestamp;

            debugListViewBtn.clicked += OnClickDebugListViewBtn;

            orderIntField.RegisterCallback <FocusOutEvent>(OnLostFocusIntField);
            executeOrderMinBtn.clicked += OnClickMinButton;
            executeOrderMaxBtn.clicked += OnClickMaxButton;
            addExcludeBtn.clicked      += OnClickAddExclude;

            SetUIActiveAtEnabled(enableToggle.value);
            SetUIActiveAtStrictMode(strictModeToggle.value);

            SetupExcludeRules();
            StrippingByVariantCollection.ResetData();
        }
Example #25
0
 private void LinkSliderToFloatField(Slider slider, IntegerField field, Action <int> updatePreferenceAction)
 {
     slider.valueChanged += (val) =>
     {
         if (!val.Equals(field.value))
         {
             var intValue = Mathf.RoundToInt(val);
             field.SetValueWithoutNotify(intValue);
             updatePreferenceAction(intValue);
         }
     };
     field.OnValueChanged((evt) =>
     {
         var newValue = evt.newValue;
         if (!newValue.Equals(slider.value))
         {
             newValue     = Math.Min(newValue, (int)slider.highValue);
             newValue     = Math.Max(newValue, (int)slider.lowValue);
             slider.value = newValue;
             field.SetValueWithoutNotify(newValue);
             updatePreferenceAction(newValue);
         }
     });
 }
Example #26
0
        private void BindElements()
        {
            var generateButton = this.Q <Button>("GenerateGeometryButton");

            generateButton.clickable.clicked += GenerateGeometry;
            generateButton.AddManipulator(generateButton.clickable);

            var generateAllButton = this.Q <Button>("GenerateGeometryAllButton");

            generateAllButton.clickable.clicked += GenerateGeometryAll;
            generateAllButton.AddManipulator(generateAllButton.clickable);

            m_OutlineDetailField  = this.Q <IntegerField>("OutlineDetailField");
            m_AlphaToleranceField = this.Q <IntegerField>("AlphaToleranceField");
            m_SubdivideField      = this.Q <IntegerField>("SubdivideField");
            m_Toggle = this.Q <Toggle>("GenerateWeightsField");

            var slider = this.Q <Slider>("OutlineDetailSlider");

            LinkSliderToFloatField(slider, m_OutlineDetailField, (x) =>
            {
                GenerateGeomertySettings.outlineDetail = x;
            });
            m_OutlineDetailField.SetValueWithoutNotify(GenerateGeomertySettings.outlineDetail);
            slider.SetValueWithoutNotify(GenerateGeomertySettings.outlineDetail);

            slider = this.Q <Slider>("AlphaToleranceSlider");
            LinkSliderToFloatField(slider, m_AlphaToleranceField, (x) =>
            {
                GenerateGeomertySettings.alphaTolerance = x;
            });
            m_AlphaToleranceField.SetValueWithoutNotify(GenerateGeomertySettings.alphaTolerance);
            slider.SetValueWithoutNotify(GenerateGeomertySettings.alphaTolerance);

            slider = this.Q <Slider>("SubdivideSlider");
            LinkSliderToFloatField(slider, m_SubdivideField, (x) =>
            {
                GenerateGeomertySettings.subdivide = x;
            });
            m_SubdivideField.SetValueWithoutNotify(GenerateGeomertySettings.subdivide);
            slider.SetValueWithoutNotify(GenerateGeomertySettings.subdivide);

            m_Toggle.value = GenerateGeomertySettings.generateWeights;
            m_Toggle.OnValueChanged((evt) =>
            {
                GenerateGeomertySettings.generateWeights = evt.newValue;
            });
        }
            public void Reset()
            {
                var property = ListElement.ListProperty;

                Clear();
                if (property.isArray)
                {
                    Controls.DeleteAllButton.SetEnabled(property.arraySize > 0);
                    var endProperty = property.GetEndProperty();

                    property.NextVisible(true);
                    int arrayIndex = 0;
                    do
                    {
                        if (SerializedProperty.EqualContents(property, endProperty))
                        {
                            break;
                        }

                        switch (property.propertyType)
                        {
                        case SerializedPropertyType.ArraySize:
                            var field = new IntegerField {
                                bindingPath = property.propertyPath
                            };
                            field.SetValueWithoutNotify(property.intValue);     // This avoids the OnValueChanged/Rebind feedback loop.
                            field.style.display = ListElement.ShowSize ? DisplayStyle.Flex : DisplayStyle.None;
                            field.RegisterValueChangedCallback(UpdateList);
                            field.label = "Size";
                            Add(field);
                            break;

                        default:
                            var newItemSection = Controls.ItemSection;
                            newItemSection.Q <PropertyField>()?.BindProperty(property);
                            (newItemSection as ItemSection).Index = arrayIndex++;
                            Add(newItemSection);
                            break;
                        }
                    } while (property.NextVisible(false));

                    property.Reset();
                }
                else
                {
                    Add(new Label("Error, Bound item is not a list or array"));
                }
            }
Example #28
0
        public override void Enable(bool fromInspector)
        {
            var indexField = new IntegerField {
                label = "index", value = foreachNode.index
            };

            foreachNode.onProcessed += () => indexField.SetValueWithoutNotify(foreachNode.index);
            controlsContainer.Add(indexField);

            var countField = new IntegerField {
                label = "count", value = foreachNode.count
            };

            foreachNode.onProcessed += () => countField.SetValueWithoutNotify(foreachNode.count);
            controlsContainer.Add(countField);
        }
Example #29
0
 void Reload()
 {
     foldout.Clear();
     lengthField = new IntegerField("Count");
     lengthField.SetValueWithoutNotify(value.Count);
     lengthField.RegisterCallback <KeyDownEvent>(ChangeCount);
     foldout.Add(lengthField);
     for (int i = 0; i < value.Count; i++)
     {
         int j = i;
         foldout.Add(ElementExtension.DrawField("element " + j, typeof(E), value[j], _newValue =>
         {
             value[j] = (E)_newValue;
         }));
     }
 }
        public void UpdateFromChildField(string bindingPath, string newValue)
        {
            while (fieldValues.Count != bindingPathArray.Length)
            {
                fieldValues.Add("auto");
            }

            var fieldIndex = Array.IndexOf(bindingPathArray, bindingPath);

            fieldValues[fieldIndex] = newValue;

            m_LastValidInput = GetFormattedInputString();
            m_TextField.SetValueWithoutNotify(m_LastValidInput);

            int.TryParse(fieldValues[0], out int intValue);
            m_DraggerIntegerField.SetValueWithoutNotify(intValue);
        }