- Home /
Question by
Ambrose998800 · Nov 19, 2021 at 05:15 PM ·
inputfieldsubmit
Change & unse InputField value
Hello
I try to change (and submit) a value of an input field over c#. Changing the value works, but it isn't submitted. That only happens when I use the mouse to highlight the input field and leave it again.
How can I use the changed value from another script?
public InputField FieldToChange;
[Space]
public IntFloat InputType = IntFloat.Integer;
[Space]
public int ChangePerActionInt = 1;
public float ChangePerActionFloat = 0.1f;
public enum IntFloat
{
Integer,
FloatNumber
}
public void IncreaseInputFieldValue()
{
//Method called by UI button
if (InputType == IntFloat.Integer)
{
int CurrentValue = int.Parse(FieldToChange.text);
FieldToChange.text = (CurrentValue + ChangePerActionInt).ToString();
}
else if (InputType == IntFloat.FloatNumber)
{
float CurrentValue = float.Parse(FieldToChange.text);
FieldToChange.text = (CurrentValue + ChangePerActionInt).ToString();
}
//Submit changed value
}
Comment
create a method SubmitText that does what you want, or use OnValueChanged.
Your answer
Follow this Question
Related Questions
How could I combine these two scripts 1 Answer
Unity 4.6 InputFields need help 1 Answer
Draw your own InputField, cursor/selection location 2 Answers
Unity 5 input field unable to store user input 1 Answer
How to validate the characters of the strings to the characters typing via mobile keyboard? 0 Answers