Sample of Money(GS2 UIKit for Unity)
This sample implements balance management of billed currency.
Repository
https://github.com/gs2io/gs2-uikit-for-unity-sample/tree/main/Money
GS2-Deploy template
https://github.com/gs2io/gs2-uikit-for-unity-sample/blob/main/Money/initialize_money_template.yaml
Project Description
Open the project and you will see the above.
When executed, the balance of the billing currency will be displayed as shown here.
First, click “Deposit(Free)”.
Your balance will be 1000.
Next, click “Deposit(Paid)”.
Your balance will be 2000. Internally, free and paid are treated as separate data, but this sample shows the total amount.
Next, click “Withdraw”.
The balance will be 1900.
Project Description
Note the hierarchy of the scene.
Canvas/MoneyWindow
Gs2MoneyOwnWalletContext
Specifies the GS2-Money wallet to be handled by the node under this GameObject.
This time, we specify a slot 0 wallet in the money-0001 namespace of GS2-Money.
Canvas/MoneyWindow/Wallet/Contents/WalletValue
Gs2MoneyOwnWalletEnabler
Enables the Value GameObject when the wallet specified in Gs2MoneyOwnWalletContext finishes loading.
Canvas/MoneyWindow/Wallet/Contents/WalletValue/Value
Gs2MoneyOwnWalletLabel.
Formats the wallet specified by Gs2MoneyOwnWalletContext in the format specified by Format. The formatted text is called back to OnUpdate(String), from which the value is reflected in the Text component.
Canvas/MoneyWindow/Input/Withdraw/Gs2MoneyWalletWithdrawAction
Reduce the balance of the charged currency.
Gs2MoneyWalletWithdrawAction.
Specify the quantity to be consumed in Count.
OnWithdrawComplete(EzWallet): Callback is returned when consumption is complete.
Canvas/MoneyWindow/Input/DepositFree
Gs2ExchangeRateModelContext
Sets the GS2-Exchange exchange rate at which GS2-Money free currency is added.
Here we specify the exchange rate named Gem0to1000 in the GS2-Exchange namespace named exchange-0005.
Canvas/MoneyWindow/Input/DepositFree/Gs2ExchangeExchangeAction
Adds the balance of the free billing currency.
Gs2ExchangeExchangeExchangeAction.
Specify the quantity to be exchanged in Count.
Canvas/MoneyWindow/Input/DepositPaid
Gs2ExchangeRateModelContext
Sets the GS2-Exchange exchange rate at which GS2-Money paid currency is added.
Here, the exchange rate named Gem1000to1000 in the namespace named exchange-0005 of GS2-Exchange is specified.
Canvas/MoneyWindow/Input/DepositPaid/Gs2ExchangeExchangeAction
Adds the balance of the paid billing currency.
Gs2ExchangeExchangeExchangeAction.
Specify the quantity to be exchanged for Count.
Process/Gs2AutoLogin
A prefab is set up to perform the login process.
sample of Account, please refer to the explanation there.