Skip to content

Smart Objects

Smart Objects is a new section where you can create your user's profile.

Screenshot

This section works very similarly to the Templates section, so you should be familiar. You can create 2 types of Smart Objects:

  • ParentBaseData - the root element for your player's profile. It can have parameters of type BaseData only.
  • BaseData - additional layer, stored in one or many ParentBaseData.

Visual Scripting

When you specify a profile, you can use it in Visual Scripting. For example, you can store the player's level, gold coins, attribution campaign, etc... in the profile and then use that data to segment players and decide which Offer you want to give to the player.

Screenshot

  • Wait Node awaits until the specified field in the profile reaches a specific value. For example, Gems > 33.
  • Get Profile Value returns the value of the specified field. For example, Level or Gems.
  • Set Profile Value changes the specified field's value in the profile.

Conditions

You can use the profile's parameters (aka User properties) in the conditions. For example, you can launch an event only for players who have at least 1000 Gems:

Screenshot

Section for programmers

It would be best to load the player's profile to make operations with it. Remember to generate the code every time you make changes in the structure of Smart Objects.

Balancy.Data.SmartStorage.LoadSmartObject<DefaultProfile>(responseData =>
{
    var profile = responseData.Data;
});

LoadSmartObject method has the last parameter DataSynchType, which determines where the data is saved.

  • Local data is saved every 5 seconds
  • Cloud data is saved every 20 seconds

If no data was changed, save is not called.

Profile Reset

If you have your Smart Object, for example, DefaultProfile, you can reset it by calling:

Balancy.Data.SmartStorage.ClearSmartObject<DefaultProfile>(<key>);

The key is the same one you used to load DefaultProfile. In most cases, it's just null.

If you need to reset the System Profile, which stores all the Scripts, Events, Offers, A/B testing, Payments, and Segmentations:

Balancy.LiveOps.Profile.Restart();

This method is asynchronous. All the callbacks will be called once again after the Reset is complete:

//It's called at the game start, when the profile is ready, and after the Restart.
ISmartObjectsEvents.OnSmartObjectsInitialized();

If you clear any profile or restart the System Profile, update all the links to them in your game, reloading the Profiles.