Skip to content

Accessing Configs Data and Profiles

Game Configs

Accessing Single Document

To access a specific document by its ID, you can use the following code:

var document = Balancy.CMS.GetModelByUnnyId<YourModel>(id);
const document = Balancy.CMS.getModelByUnnyId<YourModel>(id);

Example:

var item26 = Balancy.CMS.GetModelByUnnyId<Balancy.Models.SmartObjects.Item>("26");
Debug.Log($"item26.unnyId = {item26.UnnyId}");
Debug.Log($"item26.Name = {item26.Name}");
Debug.Log($"item26.MaxStack = {item26.MaxStack}");
const item26 = Balancy.CMS.getModelByUnnyId<SmartObjectsItem>("26");
console.log(`item26.unnyId = ${item26.unnyId}`);
console.log(`item26.Name = ${item26.name.getValue()}`);
console.log(`item26.MaxStack = ${item26.maxStack}`);

Accessing List of Documents

To get a list of all documents of a specific type, you can use the following code:

var documents = Balancy.CMS.GetModels<YourModel>(includeChildren);
const documents = Balancy.CMS.getModels<YourModel>(includeChildren);

includeChildren - if true, the method returns all documents of the specified type and their children. If false, it returns only the documents of the specified type.

Example:

var allItems = Balancy.CMS.GetModels<Balancy.Models.SmartObjects.Item>(true);
Debug.Log("AllItems count = " + allItems.Length);
foreach (var item in allItems)
{
    Debug.Log("=== New Item ===");
    Debug.Log($"unnyId = {item.UnnyId}");
    Debug.Log($"Name = {item.Name}");
    Debug.Log($"MaxStack = {item.MaxStack}");
}
const allItems = Balancy.CMS.getModels<SmartObjectsItem>(true);
console.log(`AllItems count = ${allItems.length}`);
allItems.forEach(item => {
    console.log("=== New Item ===");
    console.log(`unnyId = ${item.unnyId}`);
    console.log(`Name = ${item.name.getValue()}`);
    console.log(`MaxStack = ${item.maxStack}`);
});

Profiles

Custom Profile

If you have a custom profile, you can easily access it:

var profile = Balancy.Profiles.Get<Profile>();
const profile = Balancy.Profiles.get<Profile>();

System Profile

The system profile contains various data points that are crucial for understanding the user's interactions and status in the application.

var systemProfile = Balancy.Profiles.System;
const systemProfile = Balancy.Profiles.system;

System Profile Fields

  • Payments: Provides access to payment-related information, including purchase history, total spend, VIP level, and other payment metrics.

    • DaysForPurchase: Number of days since the last purchase.
    • Purchases: List of individual purchases made by the user.
    • TotalSpend: Total amount spent by the user.
    • LastPaymentTime: Timestamp of the last payment.
    • MaxPayment: Maximum payment made by the user.
    • PaymentsCount: Total number of payments made.
    • ResourcesMultiplier: Multiplier applied to resources from payments.
    • LevelVIP: VIP level of the user.
    • ComfortablePayment: A comfortable payment value determined by user behavior.
  • SmartInfo: Stores general LiveOps information

    • GameOffers: List of offers available in the game.
    • GameOfferGroups: Grouped offers available in the game.
    • GameEvents: List of events happening in the game.
  • SegmentsInfo: Contains information about different user segments that the profile belongs to.

    • Segments: List of user segments.
  • GeneralInfo: Holds general, non-categorized information about the user.

    • PlayTime: Total playtime of the user.
    • AppVersion: Version of the app used by the user.
    • EngineVersion: Version of the game engine.
    • Platform: Platform on which the app is running.
    • PlatformId: Identifier for the platform.
    • SystemLanguage: Language of the user's system.
    • Country: User's country.
    • TimeSincePurchase: Time elapsed since the last purchase.
    • Session: Current session number.
    • IsNewUser: Indicates if the user is new.
    • FirstLoginTime: Timestamp of the user's first login.
    • Level: Current level of the user.
    • TutorialStep: Current tutorial step the user is on.
    • TrafficSource: Source of user acquisition.
    • DontDisturb: Indicates if the user has enabled Do Not Disturb.
    • LastLoginTime: Timestamp of the last login.
    • CurrentDay: Current in-game day.
    • TrafficCampaign: Campaign associated with user acquisition.
    • ProfileId: Unique identifier for the user's profile.
    • DeviceId: Unique device identifier.
    • CustomId: Custom identifier set by the application.
    • GameLocalization: Localization settings for the game.
    • TimeSinceInstall: Time elapsed since the app was installed.
    • DeviceModel: Model of the user's device.
    • DeviceName: Name of the user's device.
    • DeviceType: Type of device (e.g., mobile, tablet).
    • OperatingSystem: Operating system of the user's device.
    • OperatingSystemFamily: Family of the operating system.
    • SystemMemorySize: Size of the system memory.
    • InstallVersion: Version of the app at the time of installation.
  • TestsInfo: Stores information regarding A/B tests that the user is currently involved in.

    • Tests: List of A/B tests.
    • AvoidedTests: List of tests that the user has opted out of.
  • AdsInfo: Provides data on ads viewed or interacted with by the user.

    • RevenueTotal: Total revenue generated from ads.
    • AdRewarded: Information about rewarded ads.
    • AdInterstitial: Information about interstitial ads.
    • AdCustom: Information about custom ads.
    • InterstitialAdsPeriod: Time period between interstitial ads.
    • RevenueToday: Revenue generated from ads today.
  • LiveOpsInfo: Contains information related to additional LiveOps activities, such as Daily Bonus.

    • DailyRewardCollected: Indicates if the daily reward has been collected.
    • DailyRewardCollectTime: Timestamp of the last daily reward collection.
  • Inventories: Tracks inventory-related data for the user, such as items and counts.

    • Currencies: Information about in-game currencies.
    • Items: Information about in-game items.

Reset Account (All Profiles)

To reset all profiles, use the following code:

Balancy.Profiles.Reset();
Balancy.Profiles.reset();

The reset is instant, and you can access fresh profiles immediately after the reset.