I am creating a program using unity that includes mathematical equation, therefore input of numbers is necessary. Input from textfield can not be used as an int or float for the equation. I tried floatfield but it does not work when I played it,the value can not be edited. So, I planned to use textfield and just convert string to float or int but the problem is I don’t know how. May ask for suggestions of what I should do or what can I do?
I am using Javascript.
thanks…
3 Answers
3it should be capital (P)
float.Parse(string);
and your variables should be “private var…”
e.g.
private var w:String = "800";
private var h:String = "600";
private var wToInt:int;
private var hToInt:int;
then in your setup function
wToInt = float.Parse(w);
hToInt = float.Parse(h);
float.parse(string);
also, this question has been asked many many times. Please use the search in the future ![]()
That link is broken, and unhelpful. The second is recursive, this is the first Google hit I got. All your belittling is for naught.
– Dynamoid_MeganThis is a new way for me also… Thanks.
I tend to use parseFloat(String);
I’ve never done it that way before. I notice you use string instead of String. Does this mean this is C# code? N.m. I’ll go check the docs for that. ![]()
and your variables should be "private var.."
– frogsbo