Exemplo n.º 1
0
        protected BaseCompoundField()
        {
            AddToClassList("compositeField");
            if (s_FieldDescriptions == null)
            {
                s_FieldDescriptions = DescribeFields();
            }

            if (s_FieldDescriptions == null)
            {
                Debug.LogError("Describe fields MUST return a non null array of field descriptions");
                return;
            }

            m_Fields = new List <DoubleField>(s_FieldDescriptions.Length);
            foreach (FieldDescription desc in s_FieldDescriptions)
            {
                var fieldContainer = new VisualElement();
                fieldContainer.AddToClassList("field");
                fieldContainer.Add(new Label(desc.name));
                var field = new DoubleField();
                fieldContainer.Add(field);
                field.OnValueChanged(e =>
                {
                    T cur = value;
                    desc.write(ref cur, e.newValue);
                    SetValueAndNotify(cur);
                });
                m_Fields.Add(field);
                shadow.Add(fieldContainer);
            }
            UpdateDisplay();
        }
Exemplo n.º 2
0
        private DoubleField AddDoubleField(EventCallback <ChangeEvent <double> > callback)
        {
            DoubleField doubleField = new DoubleField();

            base.shadow.Add(doubleField);
            doubleField.OnValueChanged(callback);
            return(doubleField);
        }
Exemplo n.º 3
0
        private DoubleField AddDoubleField(EventCallback <ChangeEvent <double> > callback)
        {
            var field = new DoubleField();

            shadow.Add(field);
            field.OnValueChanged(callback);
            return(field);
        }
Exemplo n.º 4
0
 protected BaseCompoundField()
 {
     base.AddToClassList("compositeField");
     if (BaseCompoundField <T> .s_FieldDescriptions == null)
     {
         BaseCompoundField <T> .s_FieldDescriptions = this.DescribeFields();
     }
     if (BaseCompoundField <T> .s_FieldDescriptions == null)
     {
         Debug.LogError("Describe fields MUST return a non null array of field descriptions");
     }
     else
     {
         this.m_Fields = new List <DoubleField>(BaseCompoundField <T> .s_FieldDescriptions.Length);
         BaseCompoundField <T> .FieldDescription[] array = BaseCompoundField <T> .s_FieldDescriptions;
         for (int i = 0; i < array.Length; i++)
         {
             BaseCompoundField <T> .FieldDescription desc = array[i];
             BaseCompoundField <T> $this         = this;
             VisualElement         visualElement = new VisualElement();
             visualElement.AddToClassList("field");
             visualElement.Add(new Label(desc.name));
             DoubleField doubleField = new DoubleField();
             visualElement.Add(doubleField);
             doubleField.OnValueChanged(delegate(ChangeEvent <double> e)
             {
                 T value = $this.value;
                 desc.write(ref value, e.newValue);
                 $this.SetValueAndNotify(value);
             });
             this.m_Fields.Add(doubleField);
             base.shadow.Add(visualElement);
         }
         this.UpdateDisplay();
     }
 }