Display Multiple currencies



  • Hi Baroni,
    what is a correct way to display two different currencies in Shop scene?
    have 2 lables -> coins & gems.

    Out-of-box there is only one currency to display in 'UpdateFunds' script.
    What needs to be modified to process and display 2 currencies? Expanding 'label & currency' to be an array throws some errors - not working properly.
    Thank you!



  • Hi,

    for displaying two currency funds (player funds) in the shop scene: duplicate your existing currency label with the UpdateFunds script on it. On the duplicated script, change the currency name to your second currency.

    For displaying one (or more) currency prices on the shop item, a separate IAPItem prefab is the correct approach. For example if an item costs the second currency only, you would create a new IAPItem and in its virtual price array, assign the second text slot. The reason behind this is that the price texts are filled out in the same order as currencies defined in the IAPSettings.



  • Ok, thanks! I will test suggested approach.

    I tried a different way - copied and just added similar scripting for secondary currency directly in the 'UpdateFunds' script. It's working as intended after testing!
    Perhaps your way is more simple, I'll give it a try, thanks.



  • Here is another question:
    I have a Virtual product "100gemsto10coins", set up as described here:
    https://www.rebound-games.com/forum/topic/1553/multiple-currencies/5?_=1578392043067

    selected currency is 'Coins' by default. I switch/select 'Gems' currency via drop-down.
    "100gems.." product is Virtual, consumable and I set Cost/Earnings as 100 gems.

    Here is the thing: it doesn't remember this settings every time I open my project, why?
    And if neglect to set up 100 gems again it simply crushes Unity .. ? using 2018.4.4 version

    in the Shop scene I have this Virtual product in it's own category/Tab, and after I set 100 gems as Cost/Earnings everything works fine!
    I use IncreaseFunds, and add 10 Coins while subtracting 100 gems.
    What is wrong here?



  • You're looking at very old threads, the functionality have changed multiple times since then. Please see this thread instead for a currency conversion from one currency to another:
    https://www.rebound-games.com/forum/topic/2342/

    Basically you can have a positive currency amount (substracted), and negative currency amount (added up) for the same product. You do not need custom code anymore.

    @alexsan81 said in Display Multiple currencies:

    Here is the thing: it doesn't remember this settings every time I open my project, why?

    If you mean your current currency selection in the IAP Settings editor, please see the thread above where I explain this too - you are not changing the currency for a product, you are changing your selection. The IAP Settings are saved whenever you save the scene, or close the IAP Settings window.

    And if neglect to set up 100 gems again it simply crushes Unity .. ? using 2018.4.4 version

    I haven't seen a crash with SIS yet. Please state exact repro steps for the crash in a separate topic.



  • Ok, thank you, I understand: no needs for extra code in IAPListener except Msg, that works fine - subtracting one currency and adding another simply by using this new Virtual IAP prefab's settings.

    But Unity still doesn't remember 2 currency settings just for this Virtual IAP [Virtual - Consumable - using 2 currencies settings coins and gems], after I close the program..
    any idea why? I have to set it manually every time Unity start the project: -10 coins & +100 gems in input fields.
    All others IAP products have no similar problems in terms of 'remember changes and settings', but none of those products uses two currencies as said - coins or real currency only.



  • Hello again,
    good news - everything is working properly now! :) looks like I missed something indeed.

    • using one 'UpdateFunds' script on each Label,
    • Unity saving IAP settings on exit/change,
    • Virtual prefab makes conversion from gems to coins as intended.

    Don't know what was wrong in the Demo project, but I made all from scratch and now it works. Thanks for your help!



  • Glad to hear that! Thanks for reporting back


Log in to reply