remote settings in unity cover image

Updating the game settings dynamically with Remote Settings

Almost all games that are developed in Unity uses some configuration values for the game to run. These configurations may define the difficulty of the game, the transform properties of the game object or other such properties.

In this application, we will be using remote configurations to dynamically update the values for some game objects without the requirement of rebuilding or even re-installing the game on devices.

Enabling the Analytics Service

Unity’s Remote Settings is a feature available with the Unity’s Analytics service, so make sure that you have Unity Analytics enabled for your project. To enable Unity Analytics, click the cloud button near the inspector and switch on the Toggle for Unity Analytics.

enabling unity analytics

Setting up the Project

To get started with the Project, I have simply created a 2D sprite which has a Rotator script attached to it.

using UnityEngine;

public class Rotator : MonoBehaviour
{
    public float Speed = 100f;

    void Update()
    {
        transform.Rotate(0f, 0f, speed * Time.deltaTime);
    }
}

rotator script attached to sprite

The Rotator script has a property in the inspector named “Speed” for which we have set the value as 20. But imagine if the game is deployed and there are users using the app, and we decide to change this value from 20 to 90. Here comes the role of remote settings where we can update the Rotate Speed dynamically with a few clicks that too without uploading a different release for the app.

Creating the Remote Settings key-value pairs

Go to the Unity Analytics dashboard and open the project you created. Make sure that you are signed in on the Unity Editor on your machine. Navigate to Remote Settings option under Optimization in the navigation bar.

remote settings option in side navbar

With Remote Settings selected, change the dropdown value to Development and create a new “Add New Key-Value” to create a new key named Speed of int type with value 25.

creating a new key value pair

After creating the key-value pair, click on Sync button to sync values across Remote and Unity Editor.


If you have reached till this point,


The Unity Analytics Remote Settings unitypackage

To access these remote settings in our Unity Project, we need to import the Unity Analytics Remote Settings unitypackage.

Configuring Remote Settings

After importing the above unitypackage, click on Window -> Unity Analytics -> Remote Settings. This will open a window like this.

remote settings option

Now click on Look up the key text and it will redirect to the Unity Analytics Dashboard. Or simply navigate to Analytics Settings under Settings to find your private key.

private key

Update the value for your private key and click on Next to get a screen like this.

private key added to remote sttings

Now you are all set up to use remote values in your project.

Updating the Rotator.cs script

Update the content of the Rotator script to have the following code:

using UnityEngine;

public class Rotator : MonoBehaviour
{
    public float Speed = 100f;

    private void Start()
    {
        Speed = RemoteSettings.GetInt("Speed");
    }

    void Update()
    {
        transform.Rotate(0f, 0f, Speed * Time.deltaTime);
    }
}

Observe the Start() where we are getting the value from unity remote server and sets these values dynamically.

On running, the value will be auto-updated to the value 25 that we have set on Analytics Dashboard.

playing the scene with remote values

Updating the Remote Values

To dynamically update the remote values, go to Analytics Dashboard and update the value of Speed variable to 90 and click on the Sync button.

Click on the Play button in the Editor and you will see the value is updated to 90.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.