- Home /
How to make floats in the textfield?
Hi, in my textfield I do something like this:
var px1 = 0.0;
var rtextx = "";
function OnGUI(){
px1 = select.localPosition.x;//Select: a simple transform
ptextx = px1.ToString();
ptextx = GUI.TextField(Rect (70, 40, 30, 20),ptextx, 25);
select.localPosition.x = px1 = int.Parse(ptextx);
}
But the problem is that it does not acept the period(.), but I dont know maybe the reason is different, but the thing is that when I write like 0.5 it doesnt change of position.
Another thing can be to use a floatField() but I dont know a lot of that so if some one knows about the floatField() please write a script about of how to do it. Please answer I will really apreciate it. :)
Comment
Best Answer
Answer by Eric5h5 · Nov 19, 2010 at 12:37 AM
If you want a float, you can't use int.Parse, because that just gives you an int. So you need float.Parse.
FloatField is for the editor GUI only.