Skip to content

Commit e102c2d

Browse files
authored
Add Unity VC Docs (#1026)
1 parent 5b89bcb commit e102c2d

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Fetch virtual currencies
2+
purchases.GetVirtualCurrencies((virtualCurrencies, error) =>
3+
{
4+
// TODO: Handle virtual currencies & error
5+
});
6+
7+
// Get the details of a specific virtual currency
8+
var virtualCurrency = virtualCurrencies.All[<virtual_currency_code>];
9+
var balance = virtualCurrency.Balance;
10+
var name = virtualCurrency.Name;
11+
var code = virtualCurrency.Code;
12+
13+
// Keep in mind that serverDescription may be null if no description was provided
14+
// in the RevenueCat dashboard
15+
var serverDescription = virtualCurrency.ServerDescription;
16+
17+
// Iterate through all virtual currencies
18+
foreach (var keyValuePair in virtualCurrencies.All) {
19+
var virtualCurrencyCode = keyValuePair.Key;
20+
var vc = keyValuePair.Value;
21+
Debug.Log($"{virtualCurrencyCode}: {vc.Balance}");
22+
}

docs/offerings/virtual-currency.mdx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ import fetchVCBalancesJava from "@site/code_blocks/virtual-currency/vc-balance-s
100100
import fetchVCBalancesReactNative from "@site/code_blocks/virtual-currency/vc-balance-sdk-react-native.ts?raw";
101101
import fetchVCBalancesFlutter from "@site/code_blocks/virtual-currency/vc-balance-sdk-flutter.dart?raw";
102102
import fetchVCBalancesCapacitor from "@site/code_blocks/virtual-currency/virtual-currency-balance-capacitor.ts?raw";
103+
import fetchVCBalancesUnity from "@site/code_blocks/virtual-currency/vc-balance-unity.cs?raw";
103104

104105
Fetching virtual currency balances is supported in the following SDK versions:
105106

@@ -110,6 +111,7 @@ Fetching virtual currency balances is supported in the following SDK versions:
110111
| React Native SDK | 9.1.0+ |
111112
| Flutter SDK | 9.1.0+ |
112113
| Capacitor SDK | 11.1.0+ |
114+
| Unity SDK | 8.1.0+ |
113115

114116
You can use the `virtualCurrencies()` function to retrieve a customer's balance. The function returns a `VirtualCurrencies` object, which includes the customer's balances along with each virtual currency's metadata.
115117

@@ -145,6 +147,11 @@ You can use the `virtualCurrencies()` function to retrieve a customer's balance.
145147
title: "Capacitor",
146148
content: fetchVCBalancesCapacitor,
147149
},
150+
{
151+
type: "unity",
152+
content: fetchVCBalancesUnity,
153+
name: "Unity"
154+
},
148155
]}
149156
/>
150157

0 commit comments

Comments
 (0)