Guest User

Untitled

a guest
May 21st, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. using System.Collections;
  2. using UnityEngine;
  3.  
  4. public class CurrencyConverter : MonoBehaviour
  5. {
  6. private static CurrencyConverter instance;
  7. public static CurrencyConverter Instance {
  8. get {
  9. return instance;
  10. }
  11. }
  12.  
  13. void Awake(){
  14. CreateInstance ();
  15. }
  16.  
  17. void CreateInstance () {
  18. if (instance == null) {
  19. instance == this;
  20. }
  21. }
  22.  
  23. public string GetCurrencyIntoString(float valueToConvert){
  24. string converted;
  25. if (valueToConvert >= 1000000) {
  26. converted = (valueToConvert / 1000f).ToString("f3") + " Mil";
  27. } else if (valueToConvert >= 1000) {
  28. converted = (valueToConvert / 1000f).ToString("f3") + " K";
  29. } else {
  30. converted = ("f0") + "" + valueToConvert;
  31. }
  32. }
  33. }
  34.  
  35. return converted;
Add Comment
Please, Sign In to add comment