public VFXLongSliderField() { m_Slider = new Slider(0, 1, ValueChanged, SliderDirection.Horizontal, 0.1f); m_Slider.AddToClassList("textfield"); m_Slider.valueChanged += ValueChanged; var integerField = new LongField(); integerField.RegisterCallback <ChangeEvent <long> >(ValueChanged); integerField.name = "Field"; m_Field = integerField; Add(m_Slider); Add(integerField); RegisterCallBack(); }
private void DrawValueField() { // Clear previous field if (fieldContainer.Children().Any()) { fieldContainer.Clear(); } // Create a type-specific field for each different variable type, set the right value (mainly null handling), // and register the type-specific callback VisualElement field; switch (worldVars.GetType(guid)) { case VariableType.String: field = new TextField(); field.RegisterCallback <ChangeEvent <string> >(UpdateWorldvarValue); break; case VariableType.Bool: field = new Toggle(); field.RegisterCallback <ChangeEvent <bool> >(UpdateWorldvarValue); break; case VariableType.Long: field = new LongField(); field.RegisterCallback <ChangeEvent <long> >(UpdateWorldvarValue); break; case VariableType.Double: field = new DoubleField(); field.RegisterCallback <ChangeEvent <double> >(UpdateWorldvarValue); break; default: throw new ArgumentOutOfRangeException(); } field.name = fieldName; fieldContainer.Add(field); SetFieldValue(worldVars.GetValue(guid)); }