Hi.So what i am trying to do is a test scene where i want to use the InputFields to change some variable values.Like most here I have not used these Inputfields before so I need help.
After some research i found this code but i get errors that it cannot convert from string to float and i am not even sure it is a good code.Please help ty
public InputField leftInput;
void Awake()
{
leftInput.onSubmit.AddListener((value) => SubmitName(value));
leftInput.validation = InputField.Validation.Float;
submitButton.onClick.AddListener(() => SubmitName(leftInput.value));
}
void SubmitName(float value)
{
//change a value with the input
oldvalue = value;
}
can you show me exactly how to do this because i am not quite sure
– RedDevilChange the submit function: void SubmitName(string value) { float number; if (Single.TryParse(value, out number)) { oldvalue = number; } else { Debug.Log("cannot parse value: " + value); } }
– AyAMraui am getting the following error: The name `Single' does not exist in the current context I tryed it myself before asking and was getting the same error and was thinking i am doing something wrong but i see it happends here too.
– RedDevilAt the top of the file add: using System;
– AyAMraucan you help me with one more thing?
– RedDevilRandom' is an ambiguous reference betweenUnityEngine.Random' and `System.Random' I get this after setting using System