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
1
Question by ZachAttack9280 · Sep 13, 2015 at 09:36 AM · currency

Why is the currency converter not converting money into (k) = (thousand) or (M) = (million)?

SO when I reach $1000 in my idle game, i want to to turn into $1K, same with the millions. But there are no errors and it doesnt convert? here is the code. using UnityEngine; using System.Collections;

public class CurrencyConverter : MonoBehaviour {

 private static CurrencyConverter instance;
 public static CurrencyConverter Instance{
     get{
         
         return instance;
     }
 }
 
 void awake(){
     CreateIntance();
 }
 
 void CreateIntance(){
     if (instance == null) {
         instance = this;
     }
 }
 
 public string GetCurrencyIntoString(float valueToConvert, bool currencyPerSec, bool currencyPerClick){
     string converted;
     if (valueToConvert  >= 1000000) {
         converted = (valueToConvert / 1000000f).ToString ("F3") + " M";
     } else if  (valueToConvert >= 1000) {
         converted = (valueToConvert / 1000f).ToString ("F3") + " K";
     } else {
         converted = "" + valueToConvert;
     } 
     
     if (currencyPerClick == true) {
         converted = converted + " tpc";
         
     }

     return converted;
 }

}

IS there something wrong in the code? Plz reply with the best feedback as possible, thanks.

Comment
Add comment · Show 2
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 hexagonius · Sep 19, 2015 at 09:32 PM 0
Share

what result do you get? p.s. this method can be a static one without the need of the class being instantiated.

avatar image ZachAttack9280 hexagonius · Sep 19, 2015 at 09:42 PM 0
Share

i get nothing just the number like 2742 ins$$anonymous$$d of 2.74k

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by hexagonius · Sep 19, 2015 at 10:06 PM

the code looks absolutely right. if the tostring format was wrong then at least the division should take place.have you tried setting break points Rio make absolutely sure THIS code is called and which value is generated where?

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 ZachAttack9280 · Oct 12, 2015 at 01:55 AM 0
Share

@hexagonius the total amount of money, moneyperclick, and monetpersecond

and do u $$anonymous$$d checking out some of my other question, thanks.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Rounding 235000 to 235? 2 Answers

Is Encrypted Playerprefs Safe Enough For Virtual Currency? 2 Answers

How to implement a store into mobile game 0 Answers

Help with GUI Currency 1 Answer

In-Game Currency Generation for Teams 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