- Home /
converting string from a textfield to float
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...
Answer by alptugan · Dec 29, 2013 at 03:39 PM
it 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);
Answer by testure · Sep 21, 2011 at 09:35 PM
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.
Answer by mrDude · Sep 22, 2011 at 08:27 AM
This 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. :)
Your answer
Follow this Question
Related Questions
replacing a character in a String 1 Answer
returning a variable in javascript 1 Answer
set Strings parts in different colors 1 Answer
www.data and string conversion to integer 2 Answers
ios cant access variables in array 1 Answer