Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by donskyale_412 · Sep 21, 2011 at 09:14 PM · string

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...

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
3

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);



Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image frogsbo · Jun 09, 2014 at 02:26 PM 0
Share

and your variables should be "private var.."

avatar image
0

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 :)

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Jeff-Kesselman · Jun 09, 2014 at 02:32 PM -1
Share

or you could http://bit.ly/1k$$anonymous$$wGcx

avatar image Dynamoid Megan · Jun 23, 2015 at 07:45 PM 1
Share

That link is broken, and unhelpful. The second is recursive, this is the first Google hit I got. All your belittling is for naught.

avatar image
0

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. :)

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges