> For the complete documentation index, see [llms.txt](/llms.txt)

# Sample of Money(GS2 UIKit for Unity)

sample implementation of GS2-Money functionality using 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

![img_13.png](img_13.png)

Open the project and you will see the above.

![img_14.png](img_14.png)

When executed, the balance of the billing currency will be displayed as shown here.

First, click "Deposit(Free)".

![img_15.png](img_15.png)

Your balance will be 1000.

Next, click "Deposit(Paid)".

![img_16.png](img_16.png)

Your balance will be 2000.
Internally, free and paid are treated as separate data, but this sample shows the total amount.

Next, click "Withdraw".

![img_17.png](img_17.png)

The balance will be 1900.

## Project Description

![img_12.png](img_12.png)

Note the hierarchy of the scene.

### Canvas/MoneyWindow

![img.png](img.png)

**Gs2MoneyOwnWalletContext**

Specifies the GS2-Money wallet to be handled by the node under this GameObject.

![img_2.png](img_2.png)
![img_1.png](img_1.png)

This time, we specify a slot 0 wallet in the money-0001 namespace of GS2-Money.

### Canvas/MoneyWindow/Wallet/Contents/WalletValue

![img_3.png](img_3.png)

**Gs2MoneyOwnWalletEnabler**

Enables the Value GameObject when the wallet specified in Gs2MoneyOwnWalletContext finishes loading.

### Canvas/MoneyWindow/Wallet/Contents/WalletValue/Value

![img_4.png](img_4.png)

**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

![img_5.png](img_5.png)

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

![img_7.png](img_7.png)

**Gs2ExchangeRateModelContext**

Sets the GS2-Exchange exchange rate at which GS2-Money free currency is added.

![img_9.png](img_9.png)
![img_8.png](img_8.png)

Here we specify the exchange rate named Gem0to1000 in the GS2-Exchange namespace named exchange-0005.

### Canvas/MoneyWindow/Input/DepositFree/Gs2ExchangeExchangeAction

![img_6.png](img_6.png)

Adds the balance of the free billing currency.

**Gs2ExchangeExchangeExchangeAction**.

Specify the quantity to be exchanged in Count.

### Canvas/MoneyWindow/Input/DepositPaid

**Gs2ExchangeRateModelContext**

![img_10.png](img_10.png)

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

![img_11.png](img_11.png)

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.




