Menu

Unity SDK

1. Introduction

1.1 Overview

        In order to reduce the trouble for developers to update app version frequently, SolarEngine introduces Remote Config (Online Parameter) feature. By delivering parameters, developers can update app content remotely at any time.

1.2 Application

       This document is applicable to:

  1. Mobile apps or products developed using Unity.
  2. Android 5.0 and above, and iOS 11.0 and above.
  3. WeChat/Kwai mini-games transferred from apps via Unity.

1.3 SDK Download

  • The latest SDK version is : V1.3.0.6
  • To enable Remote Config feature, please download the solarengine-unity-sdk.unitypackage from the Unity SDK integration document.
  • Windows not supported

2. Integrate SDK

Since the remote config SDK is a plugin of SolarEngine SDK, developers do not need to configure it separately when integrating. It is enabled by default. Developers can choose to cancel it on the setting panel.

ParameterParameter MeaningTypeRequired
iOSWhether to use the remote config plugin on the iOS platformboolNO
AndroidWhether to use the remote config plugin on the Android platformboolNO
MiniGameWhether to use the remote config plugin on the MiniGame platformboolNO
OpenHarmonyWhether to use the remote config plugin on the OpenHarmony platformboolNO
Mac OSWhether to use the remote config plugin on the MiniGame platformboolNO

3. SDK Method Introduction

3.1 SDK Initialization

       Since Remote Config SDK is a plugin of SolarEngine SDK, Remote Config SDK initialization depends on the SolarEngine SDK initialization.

Function

public static void initSeSdk(string appKey, SEConfig seConfig, RCConfig rcConfig)

Parameters

ParameterParameter MeaningTypeRequired
appKeyappkey obtained from SE dashboardStringYES
seConfigSE SDK configSEConfigYES
rcConfigSE remote config SDK configRCConfigYES

seConfig parameter description: please refer to the Unity SDK Access documentation.

rcConfig parameter description:

Parameter NameMeaningTypeRequired
enableWhether to enable the parameter delivery SDK (Default false)boolYES
mergeTypeServer and SDK merge type
(For details, please refer to the explanation below)
RCMergeTypeNO
customIDPropertiesCustom ID, matching the custom ID set by the user on the dashboardDictionary<string, object> NO
customIDEventPropertiesCustom ID event property value, matching the event attribute value set by the user on the dashboard.Dictionary<string, object> NO
customIDUserPropertiesCustom ID user property value, matching the user attribute value set by the useron the dashboard.Dictionary<string, object> NO

Introduction to mergeType (merge strategy):

ParameterParameter Meaning
ByUserWhen the app is first launched or the version is updated, use the server configuration to merge with the user's default configuration. This method can clear the local cache configuration.
ByDefaultUse the server configuration to merge with the user's local cache configuration.


Note: Developers who use the parameter delivery SDK need to preset a default configuration into the app through API. The SDK uses this default configuration as an alternative. For specific methods, please refer to the "Set Default Configuration" section.

Code Snippet

SEConfig seConfig = new SEConfig();
seConfig.logEnabled = true;

RCConfig rcConfig = new RCConfig();
rcConfig.enable = true;
rc.mergeType = RCMergeType.byUser;
Dictionary<string, object> customIDProperties = new Dictionary<string, object>();
customIDProperties.Add("id_key1", "id_value1");
customIDProperties.Add("id_key2", "id_value2");
rcConfig.customIDProperties = customIDProperties;
Dictionary<string, object> customIDEventProperties = new Dictionary<string, object>();
customIDEventProperties.Add("event_key1", "event_value1");
customIDEventProperties.Add("event_key2", "event_value2");
rcConfig.customIDEventProperties = customIDEventProperties;
Dictionary<string, object> customIDUserProperties = new Dictionary<string, object>();
customIDUserProperties.Add("user_key1", "user_value1");
customIDUserProperties.Add("user_key2", "user_value2");
rcConfig.customIDUserProperties = customIDUserProperties;


SolarEngine.Analytics.initSeSdk("appkey",seConfig, rcConfig);

3.2 Set Default Configuration

       Developers need to preset a default configuration into the app through API. The SDK uses this default configuration as an alternative.

Function

 public void SetRemoteDefaultConfig(Item[] defaultConfig)
ParameterParameter MeaningTypeRequired
defaultConfigThe default configuration passed by the developerItem[]Yes

      We have encapsulated the function accordingly, allowing developers to call the encapsulated method and pass in the default configuration.

Function


public Item stringItem(string name, string value);
public Item intItem(string name, int value);
public Item boolItem(string name, bool value);
public Item jsonItem(string name,Dictionary<string,object> value);

Code Example

  SESDKRemoteConfig remoteConfig = new SESDKRemoteConfig();
  List<object> list = new List<object>();
       list.Add(1);
        list.Add(2);
        list.Add(3);
  Dictionary<string, object> defaultConfig6 = new Dictionary<string, object>();
        defaultConfig6.Add("name", "test");
        defaultConfig6.Add("age", 1);
        defaultConfig6.Add("list", list);

        SESDKRemoteConfig.Item itemString = remoteConfig.stringItem("test", "test");
        SESDKRemoteConfig.Item itemJson = remoteConfig.jsonItem("testjson", defaultConfig6);
        SESDKRemoteConfig.Item itemBool = remoteConfig.boolItem("testbool", true);
        SESDKRemoteConfig.Item itemInt = remoteConfig.intItem("testint", 1);
        SESDKRemoteConfig.Item[] defaultConfigArray= new SESDKRemoteConfig.Item[]{itemString,itemJson,itemBool,itemInt};
remoteConfig.SetRemoteDefaultConfig(defaultConfigArray);

3.3 Set Custom Event Properties

       Developers can set custom event properties, and the parameter delivery SDK will bring this property when requesting server configuration for server-side parameter matching.

Function

public void SetRemoteConfigEventProperties(Dictionary<string, object> properties)
ParameterParameter MeaningParameter TypeRequired
propertiesCustom event propertiesDictionary<string, object>Yes

Code Example

SESDKRemoteConfig remoteConfig = new SESDKRemoteConfig();
Dictionary<string, object> eventProperties = new Dictionary<string, object>();
eventProperties.Add("event_pro1", "event_value1");
eventProperties.Add("event_pro2", "event_value2");
remoteConfig.SetRemoteConfigEventProperties(eventProperties);
 

Note:

      Please do not pass custom event properties with keys starting with an underscore "_". The SDK will discard such properties by default.

3.4 Set Custom User Properties

       Developers can set custom user properties. The parameter delivery SDK will bring this property when requesting server configuration for server-side parameter matching.

Function

public void SetRemoteConfigUserProperties(Dictionary<string, object> properties)
ParameterParameter MeaningParameter TypeRequired
propertiesCustom user propertiesDictionary<string, object>Yes

Code Example

SESDKRemoteConfig remoteConfig = new SESDKRemoteConfig();
Dictionary<string, object> userProperties = new Dictionary<string, object>();
userProperties.Add("user_pro1", "user_value1");
userProperties.Add("user_pro2", "user_value2");
remoteConfig.SetRemoteConfigUserProperties(userProperties);

Note:

      Please do not pass in custom user properties with keys starting with an underscore "_". The SDK will discard such properties by default.

3.5 Fetch Remote Config Parameters

       The Remote Config SDK provides two methods for retrieving parameter configuration: synchronous and asynchronous.

  • Sync: Developers can directly get the result by calling the corresponding method.
  • Async: The result needs to be obtained after the callback is completed.

Note:

      When retrieving parameters synchronously or asynchronously, the SDK will trigger an event to report which test group the user is assigned to. Therefore, it is recommended to retrieve parameters only when the user reaches the test scenario. Please don't retrieve parameters too early.

1) Fetch Remote Config Parameters (Sync)

Function

//Non-Harmony platforms
public string FastFetchRemoteConfig(string key)

//Harmony
public void FastFetchRemoteConfig(string key,Action<string>callback)
ParameterParameter MeaningTypeRequired
keyParameter delivery key, corresponding to the parameter key configured by the user on the dashboardStringYes

Returned value: Returns the value of the corresponding key, string type.

Code Example

//Non-Harmony platforms
SESDKRemoteConfig remoteConfig = new SESDKRemoteConfig();
//Default string type values returned. Deverlopers can customize data type. Here we provide bool type example.
string result = remoteConfig.FastFetchRemoteConfig("key");
bool boolResult = bool.Parse(result);

//Harmony

remoteConfig.FastFetchRemoteConfig("key", onFetchRemoteConfigCallbacks);
private void onFetchRemoteConfigCallbacks(string result)
{
    //Default string type values returned. Deverlopers can customize data type. Here we provide bool type example.
   bool boolResult = bool.Parse(result);
}

2) Fetch All Remote Config Parameters (Sync)

Function

//Non-Harmony platforms
public Dictionary<string, object> FastFetchRemoteConfig()

//Harmony
public void FastAllFetchRemoteConfig( Action<Dictionary<string, object>> callback)

Returned value: Returns the value of all parameter delivery configurations (Type: Dictionary<string, object>)

Code Example

//Non-Harmony platforms
SESDKRemoteConfig remoteConfig = new SESDKRemoteConfig();
Dictionary<string,object> result = remoteConfig.FastFetchRemoteConfig();

//Harmony
remoteConfig.FastAllFetchRemoteConfig(onFetchRemoteConfigCallback);
private void onFetchRemoteConfigCallback(Dictionary<string, object> result)
{
    string str = JsonConvert.SerializeObject(result);
    Debug.Log(str);
}

3) Fetch Remote Config Callback (Async)

Function

public void AsyncFetchRemoteConfig(string key, FetchRemoteConfigCallback callback)
ParameterParameter MeaningParameter TypeRequired
keyParameter delivery key, corresponds to the parameter key configured by the user in the background.StringYes
callbackParameter delivery asynchronous callbackFetchRemoteConfigCallbackYes

Code Example

private void onFetchRemoteConfigCallback(string result) {
    //Default string type values returned. Deverlopers can customize data type. Here we provide bool type example.
    bool boolResult = bool.Parse(result);
}

SESDKRemoteConfig remoteConfig = new SESDKRemoteConfig();
remoteConfig.AsyncFetchRemoteConfig("key", onFetchRemoteConfigCallback);

4) Fetch All Remote Config Callback (Async)

Function

public void AsyncFetchRemoteConfig(FetchAllRemoteConfigCallback callback)
ParameterParameter MeaningParameter TypeRequired
callbackParameter delivery asynchronous callbackFetchAllRemoteConfigCallbackYes

Code Example

private void onFetchAllRemoteConfigCallback(Dictionary<string, object> result) {
    //result: all the remote config information fetched asynchronously
}

SESDKRemoteConfig remoteConfig = new SESDKRemoteConfig();
remoteConfig.AsyncFetchRemoteConfig(onFetchAllRemoteConfigCallback);

5) Obfuscation Config

HarmonyOS Platform

If obfuscation is needed during packaging, please add the following code to the configuration.

./oh_modules/@solarengine/remoteconfig


Previous
Web SDK
Next
Data Management
Last modified: 2025-08-06Powered by