Skip to content

Smart Objects

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

Screenshot

This section works very similar to the Templates section, so you should be familiar with it. 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.

Best Practices

For optimal performance and consistency, it's highly recommended to initiate the loading of all SmartObjects only after the OnSmartObjectsInitialized callback is invoked. This method serves as a reliable trigger, ensuring that all preliminary processes have been settled.

Here's how to leverage this practice:

  1. Caching SmartObjects: Upon the trigger of OnSmartObjectsInitialized, load and cache all relevant SmartObjects. This consolidated pool of objects can then be conveniently accessed throughout your project, reducing redundant calls and enhancing access speed.

  2. Maintaining Data Integrity: The system is designed to recall OnSmartObjectsInitialized under specific circumstances, such as when a player switches accounts or when data discrepancies are detected. This re-invocation ensures that you have the opportunity to refresh and update the cached data, maintaining accuracy and consistency for the user experience.

  3. Resilience to Change: This practice safeguards against potential conflicts or data loss, as the callback provides a stable point of reference and recovery, ensuring that the most current and accurate data is presented post-resolution.

Implementing this approach streamlines data management within your project, bolsters stability, and ensures a seamless, reliable experience for your players.

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 Smart Objects, including the System Profile, which stores all the Scripts, Events, Offers, A/B testing, Payments, and Segmentations, use Restart method:

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.