Sprite Storing on JSON Based Remote Configs

LionSDK allows storing Sprites in Remote Config services as references. Conversion is handled automatically when the ref: keyword is used with Remote Config keys.

Adding Sprites as Remote Config Values

Reference values should have this format in the main JSON data: ref:[SPRITE_REMOTE_CONFIG_ID]

Using Sprite Reference in JSON Example:

{
  "isBoxed": true,
  "boxSprite": "ref:ui_chest_01",               //Reference for ui_chest_01 remote config value
  "openedBoxSprite": "ref:ui_chest_01_opened",  //Reference for ui_chest_01_opened remote config value
  "Rewards": [
    {
      "sprite": "ref:ui_icon_coin",             //Reference for ui_icon_coin remote config value
      "id": "coins",
      "amount": 100
    }
  ]
}

In this example, we should create three remote config keys by using ref IDs: ui_chest_01_opened , ui_chest_01 , ui_icon_coin . They will automatically converted to sprites by our converter.

Getting sprites individually in the code:

Sprite logo = RemoteConfigsController.GetValue<Sprite>("Icons/sprite",null);
imageComponent.sprite = logo;

We have 3 options to store sprite data and use values.

1) Storing Sprites as Base64 String Values on Remote Configs

We use base64: prefix for base64 string values to store on Remote Configs.

Sample Base64 as a Remote Config Value:

base64:iVBORw0KGgoAAAANSUhEUgAAAbgAAAFVCAYAAACdEPrvAAAgAElEQVR4Aey9B5xkR3Uufj...

Preparing Sprites for Conversion

Sample settings.
An error will appear in the data field if the sprite is not set up correctly for conversion.
Sample JSON and Sprite Values generated by Remote Config Visualizer.

2) Storing Sprites in Resources Folder and Referring The File Path

For referencing a Sprite in Resources folder we use resources: prefix and then we add path of the file as remote config value.

Assume you have a sprite called sprite.png inside Assets/Resources/Icons/.

Using Resources as Remote Config Value Example:

resources:Icons/sprite

3) Storing Sprites in the Project and Adding References to Reward Icons Scriptable Object

LionSDK automatically generates RewardIcons.asset file in the project. You can add a sprite with new unique ID to reference in Remote Configs. For referencing them we use ico: prefix and unique ID as remote config value.\

RewardIcons.asset path:

Assets/LionStudios/Resources/RewardIcons.asset

Using Ico as Remote Config Value Example:

ico:ui_icon_coin

Last updated