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
1
Question by TurboHermit · May 24, 2012 at 02:18 PM · variablestringdotsnumber

Label dots in between numbers (currency formatting)

I couldn't make up a better name for the question. I've got a label which shows a variable representing your current money. The things is, the amount of money you have can be immense. Is there a way (in script) to show the variable with dots between the 'thousands'. Once again, not a very clear description. I'm trying to figure how to do this:

$2.500.000,-

Instead of this:

$2500000,-

Is there a way to do this?

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
4
Best Answer

Answer by aldonaletto · May 24, 2012 at 02:38 PM

This is currency formatting. You can format values as currency in .NET with String.Format("{0:C}", value):

 var money: float = 2500000;
 print(String.Format("{0:C}", money);
Comment
Add comment · Show 8 · 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 TurboHermit · May 24, 2012 at 02:43 PM 0
Share

And how would I implement that in this code?

GUI.Label (Rect (20, Screen.height - 433, 300, 75), "$$anonymous$$oney: $" + main.Current$$anonymous$$oney + ",-");

avatar image Lo0NuhtiK · May 24, 2012 at 02:51 PM 0
Share

.... "$$anonymous$$oney: " + String.Format("{0:C}", main.Current$$anonymous$$oney) + ",-") ;

avatar image TurboHermit · May 24, 2012 at 03:01 PM 0
Share

Works like a charm! Thanks guys!

avatar image whydoidoit · May 24, 2012 at 03:11 PM 2
Share

Just remember that {0:C} is going to show Euros in Europe (for now at least:), £ in the U$$anonymous$$, $ in the US etc.

avatar image semiessessi · Aug 14, 2013 at 02:03 PM 0
Share

actually this doesn't show £ in the U$$anonymous$$!!!

Show more comments
avatar image
3

Answer by whydoidoit · May 24, 2012 at 02:38 PM

When you put the text into the label just use String.Format("{0:C}", yourNumberHere) for your local currency or String.Format("${0:#,0}", yourNumberHere) for one that always starts with a dollar - it should format according to the locale of the device using "." and "," relative to how the user expects to see it.

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

8 People are following this question.

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

Related Questions

variables as GUI 1 Answer

String + Variable to retrieve a variable? 2 Answers

Edit Variables From Game! 1 Answer

Make user change variable only by specific number 1 Answer

Input Field Text string to string variable. (const string) 0 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