2. Attributes API
Manage dynamic, changing state during gameplay to provide context to the LFM.
Context is Everything
While Session data remains completely static, Attributes describe the rapidly changing runtime context of your game.
When the Large Feelings Model (LFM) processes raw kinematic telemetry (like rapid screen tapping), it desperately needs to know what the user is experiencing to label the behavior correctly. Rapid tapping during a boss fight indicates high engagement and flow. Rapid tapping on a frozen loading screen indicates severe frustration. The Attributes API provides this context.
A reminder
You can only set basic key - value pairs here. No complex values are allowed, instead, set multiple pairs where complexity is needed.
The API Surface
The SDK exposes several Quality of Life (QoL) methods to make managing this state as frictionless as possible within standard Unity lifecycles.
1. Setting Individual Attributes
Use SetAttribute to add a new key or overwrite an existing one. This is ideal for isolated state changes, like a player picking up a specific weapon or taking damage.
using NX10;
using UnityEngine;
public class PlayerController : MonoBehaviour
{
public void OnWeaponEquipped(string weaponName)
{
// The SDK updates its local cache and fires a snapshot to the backend
NX10Manager.Instance.SetAttribute("activeWeapon", weaponName);
}
public void OnHealthChanged(int currentHealth)
{
NX10Manager.Instance.SetAttribute("playerHealth", currentHealth);
}
}2. Bulk Updates
When a player loads into a new level, dozens of contextual parameters might change at once. Use SetAttributes to merge a dictionary of values into the current state. The SDK will update its cache and dispatch a single network request for the bulk update.
using NX10;
using System.Collections.Generic;
using UnityEngine;
public class LevelManager : MonoBehaviour
{
public void OnLevelStarted(int levelIndex, string difficulty, string biome)
{
var levelContext = new Dictionary<string, object>
{
{ "uiScreen", "gameplay" },
{ "currentLevel", levelIndex },
{ "currentDifficulty", difficulty },
{ "biome", biome },
{ "isBossActive", false }
};
NX10Manager.Instance.SetAttributes(levelContext);
}
}3. Removing Attributes
Sometimes state becomes irrelevant. For example, if a player leaves a boss fight, keeping bossHealth in the state dictionary might confuse the telemetry tagging. Use RemoveAttribute to strip specific keys out of the active state.
using NX10;
using UnityEngine;
public class BossEncounter : MonoBehaviour
{
public void OnBossDefeated()
{
NX10Manager.Instance.SetAttribute("isBossActive", false);
// Clean up temporary variables specific to this encounter
NX10Manager.Instance.RemoveAttribute("bossName");
NX10Manager.Instance.RemoveAttribute("bossHealth");
NX10Manager.Instance.RemoveAttribute("bossPhase");
}
}4. Clearing State
When transitioning back to a Main Menu or Title Screen, you usually want to wipe the slate completely clean to avoid gameplay variables bleeding into menu telemetry. ClearAttributes instantly empties the local cache.
using NX10;
using UnityEngine;
public class SceneTransitionManager : MonoBehaviour
{
public void ReturnToMainMenu()
{
// Wipes all active attributes
NX10Manager.Instance.ClearAttributes();
// Set the new baseline state for the menu
NX10Manager.Instance.SetAttribute("uiScreen", "main_menu");
}
}Data Constraints
Supported Value Types
- Strings (e.g., "gameplay", "pause_menu")
- Integers & Longs (e.g., 5, 1000)
- Floats & Doubles (e.g., 98.5)
- Booleans (true, false)
- Null
Unsupported Types
Like the Session initialization, the Attributes API enforces a flat structure.
- No nested dictionaries or objects
- No Lists or Arrays of any kind
- No custom class objects
