Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 RickyX · Oct 09, 2014 at 05:33 PM · floatintconvert

Turn float to int

I multiplied a float with Time.deltaTime like: SomeFloat -= 0.001 * Time.deltaTime And i'm showing the "SomeFloat" float graphicaly with GUI.Label, and it works like it's supposed to, reduces by -0.001 every second... I'm actually making a precent, like how much % is left of "SomeFloat" in the GUI.Label, It's good, but it's like 99.999 %, 99.998 %, 9.997 .... 0.001 % But i want it to display it as an classic 2 or 1 spaces long number (Like 99.998 % shows like 99%) So i never worked with ints, using C#, but my guess is that int doesen't show dots, just full numbers... SOOO, i guess i need to show float as an int ? Or is there some other solution ? I don't know anymore, this is probabbly confusing, i couldn't explain better, i'm sorry.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Kiwasi · Oct 09, 2014 at 05:39 PM

ToString is what you want. Try this answer out.

http://answers.unity3d.com/questions/12981/seperate-large-numbers-with-comma.html

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 RickyX · Oct 09, 2014 at 07:33 PM 0
Share

Found a way before i read this answer, but thank you for your time anyway

avatar image
1

Answer by RickyX · Oct 09, 2014 at 07:29 PM

I came up to an answer by searching, i just made a new int, and said it's = to (int)Somefloat, which turns somefloat to an int

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 Kiwasi · Oct 09, 2014 at 10:39 PM 0
Share

Just be aware that casting to an int will require some more work if you want to add commas, or a couple of decimal points.

avatar image Kadeo · Jun 10, 2016 at 06:41 PM 0
Share

Thanks for this, I had the same question and this totally helped

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

31 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Cannot implicitly convert type `float' to `int'. An explicit conversion exists (are you missing a cast?) 1 Answer

Cannot convert 'callable(int) as float' to 'float'. 1 Answer

Possible to convert a Float into an Int? 3 Answers

Javascript int to float 1 Answer

GUI.Label shows volume from a slider 3 Answers


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