/// <summary> /// Called when the input field's text is changed. /// </summary> /// <param name="text">The new text.</param> private void OnTextChanged(GameObject _, string text) { if (float.TryParse(text, out float newValue)) { if (limits != null) { newValue = limits.ClampToRange(newValue); } // Record the valid value value = newValue; } Update(); }
protected override IUIComponent GetUIComponent() { var cb = new PTextField() { OnTextChanged = (obj, text) => { if (float.TryParse(text, out float newValue)) { if (limits != null) newValue = limits.ClampToRange(newValue); // Record the valid value value = newValue; } Update(); }, ToolTip = ToolTip, Text = value.ToString(), MinWidth = 64, MaxLength = 16, Type = PTextField.FieldType.Float }; cb.OnRealize += OnRealizeTextField; return cb; }