Ejemplo n.º 1
0
 /// <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();
 }
Ejemplo n.º 2
0
		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;
		}