Configuration
Retrieve your Economy configuration using the Configuration namespace.
Read time 4 minutesLast updated a day ago
The methods in the
ConfigurationSyncConfigurationAsync()GetCurrencies()SyncConfigurationAsync()SyncConfigurationAsync
Gets the currently published Economy configuration and caches it in the SDK. You must call this method before calling any other configuration methods (for example,GetCurrencies()await EconomyService.Instance.Configuration.SyncConfigurationAsync();
Currencies
GetCurrencies
Retrieves all currencies from your cached configuration. Returns a list ofCurrencyDefinitionList<CurrencyDefinition> definitions = EconomyService.Instance.Configuration.GetCurrencies();
GetCurrency
Retrieves a specificCurrencyDefinitionnullstring currencyID = "GOLD_BARS";CurrencyDefinition goldCurrencyDefinition = EconomyService.Instance.Configuration.GetCurrency(currencyID);
CurrencyDefinition
ACurrencyDefinition- : The currency ID.
Id - : The human readable currency name.
Name - : The type of item as defined in the Economy Configuration page (for all
Typeobjects this will beCurrencyDefinition).CURRENCY - : The amount of currency a player is given initially.
Initial - : (Optional, a value of 0 indicates no maximum) The maximum amount of currency available for a player to own.
Max - : Any custom data associated with this currency definition, as a
CustomData(see Using CustomDataDeserializable).Dictionary<string, object> - : The date this currency was created. It is an EconomyDate object.
Created - : The date this currency was modified. It is an EconomyDate object.
Modified
GetPlayerBalance
This method gets the balance for the currently signed in player of the currency specified in theCurrencyDefinitionPlayerBalancestring currencyID = "GOLD_BARS";CurrencyDefinition goldCurrencyDefinition = EconomyService.Instance.Configuration.GetCurrency(currencyID);PlayerBalance playersGoldBarBalance = await goldCurrencyDefinition.GetPlayerBalanceAsync();
Inventories
GetInventoryItems
Retrieves all inventory items from your cached configuration. Returns a list ofInventoryItemDefinitionList<InventoryItemDefinition> definitions = EconomyService.Instance.Configuration.GetInventoryItems();
GetInventoryItem
Retrieves a specificInventoryItemDefinitionnullstring itemID = "SWORD";InventoryItemDefinition definition = EconomyService.Instance.Configuration.GetInventoryItem(itemID);
InventoryItemDefinition
AInventoryItemDefinition- : The inventory item ID.
Id - : The human readable name.
Name - : The type of item as defined in the Economy Configuration page (for all
Typeobjects this will beInventoryItemDefinition).INVENTORY_ITEM - : Any custom data associated with this item definition, as a
CustomData(see Using CustomDataDeserializable).Dictionary<string, object> - : The date this item was created. It is an EconomyDate object.
Created - : The date this item was modified. It is an EconomyDate object.
Modified
GetAllPlayersInventoryItems
Gets all of the player's inventory items for the currently logged in player. Returns aGetInventoryResultstring itemID = "SWORD";InventoryItemDefinition definition = EconomyService.Instance.Configuration.GetInventoryItem(itemID);GetInventoryResult allThePlayersSwords = await definition.GetAllPlayersInventoryItemsAsync();
Purchases
Virtual purchases
GetVirtualPurchases
Retrieves all virtual purchases from your cached configuration. Returns a list ofVirtualPurchaseDefinitionList<VirtualPurchaseDefinition> definitions = EconomyService.Instance.Configuration.GetVirtualPurchases();
GetVirtualPurchase
Retrieves a single virtual purchase from your cached configuration. Returns a singleVirtualPurchaseDefinitionstring purchaseId = "VIRTUAL_PURCHASE_ID"VirtualPurchaseDefinition definition = EconomyService.Instance.Configuration.GetVirtualPurchase(purchaseId);
VirtualPurchaseDefinition
AVirtualPurchaseDefinitionVirtualPurchaseDefinition- : The purchase definition ID.
Id - : The human readable name.
Name - : The type of item as defined in the Economy Configuration page (for all
Typeobjects this will beVirtualPurchaseDefinition).VIRTUAL_PURCHASE - : Any custom data associated with this purchase definition, as a
CustomData(see Using CustomDataDeserializable).Dictionary<string, object> - : Any custom data associated with this purchase definition, as an
CustomDataDeserializable(see Using CustomDataDeserializable).IDeserializable - : The date this purchase definition was created. It is an EconomyDate object.
Created - : The date this purchase definition was modified. It is an EconomyDate object.
Modified - : A list of the costs associated with this purchase, as a
Costs.PurchaseItemQuantity - : A list of the rewards associated with this purchase, as a
Rewards.PurchaseItemQuantity
Real money purchases
GetRealMoneyPurchases
Retrieves all real money purchases from your cached configuration. Returns a list ofRealMoneyPurchaseDefinitionList<RealMoneyPurchaseDefinition> definitions = EconomyService.Instance.Configuration.GetRealMoneyPurchases();
GetRealMoneyPurchase
Retrieves a single real money purchase from your cached configuration. Returns a singleRealMoneyPurchaseDefinitionstring purchaseId = "REAL_MONEY_PURCHASE_ID"RealMoneyPurchaseDefinition definition = EconomyService.Instance.Configuration.GetRealMoneyPurchase(purchaseId);
RealMoneyPurchaseDefinition
ARealMoneyPurchaseDefinitionRealMoneyPurchaseDefinition- : The purchase definition ID.
Id - : The human readable name.
Name - : The type of item as defined in the Economy Configuration page (for all
Typeobjects this will beRealMoneyPurchaseDefinition).MONEY_PURCHASE - : Any custom data associated with this purchase definition, as a
CustomData(see Using CustomDataDeserializable).Dictionary<string, object> - : The date this purchase definition was created. It is an EconomyDate object.
Created - : The date this purchase definition was modified. It is an EconomyDate object.
Modified - : The store identifiers for this purchase. It is a StoreIdentifiers object.
StoreIdentifiers - : A list of the rewards associated with this purchase, as a
Rewards.PurchaseItemQuantity
StoreIdentifiers
AStoreIdentifersPurchaseItemQuantity
APurchaseItemQuantity- : An
Itempointing to the item definition represented by this quantity.EconomyReference - : The amount of the item represented, as an integer.
Amount
EconomyReference
AnEconomyReference- which fetches the associated item.
GetReferencedConfigurationItem()
Using CustomDataDeserializable
Custom data is set in the Unity Dashboard. Select a currency, inventory item, or purchase, navigate to Custom data, then add the data in a JSON format. Custom data is stored inCustomDataDeserializableIDeserializableYou can deserialize the instance data with the following:{ "rarity": "purple"}
class MyCustomData{ public string Rarity}MyCustomData fetchedCustomData = fetchedConfigItem.CustomDataDeserializable.GetAs<MyCustomData>();string rarity = fetchedCustomData.Rarity;