Unity's Remote Config is a powerful tool that allows developers to change their game's behavior and appearance without requiring an update to the app. This is particularly useful for tweaking game balance, conducting A/B testing, or delivering seasonal content. In this blog, we'll explore how to use Unity's Remote Config to manage JSON data.

Before we get started, we need a Unity project set up and ready to go.

  • Setting Up Unity Remote Config

Now, Open package manager in the Unity developer. Choose the Remote Config package from Unity Registry and import in the package.

AD_4nXf28Kq-Hxzmc80JGVVq153Lp81cpow4E_lxKfzXT1muwGZgdUE0f_lZ5Ymnlvz6Kv44p1-6A3EKUH9SPLDPBS61JB6ms7c7_aQz_grlEd8F2b08RC5yEuwx4ae15qjrYoV6M217iA5IksCnknKB8qJSSYkd?key=ianDbsjkc0RXj3caq9iwJw

  • Configure JSON Data in Unity Dashboard

     Go to the Unity Dashboard and select your project. Navigate to ‘Remote Config’ and click on Add Key button to add JSON data in remote config.

AD_4nXc8jturAejbBfkS5_Ory7ad32_LLRKpaAq9WnX9WMPMZ6nvgMwje2JwNpDsebeIEpyNWocfb6IxrhBIUVEI-s1oommJKnDFIQ958iXUWctg4jN7sZFrN86i6ZVDLXPx0PwqhOSEb9rdlvxnf36SKUdbFhk?key=ianDbsjkc0RXj3caq9iwJw

Now, set the key (e.g., ‘gameConfig’), set the type to JSON and click on the Next button.

AD_4nXdjgrIsEJ3XfBcnp9Y9XHrwIKog42g75LDjfWXLQUEl-3CQCqRSZ5gRcWtmWymHSYA-clHLhWtZy76qlm2MDjn6Ddy15h7oXyYnmLmFXuPA0Wqgh0btEgAvy4LA-DqBb3iBPYq4rMZxF6cjMmH-KQHo6BCp?key=ianDbsjkc0RXj3caq9iwJw

Add JSON data as shown here and click on the Submit button

AD_4nXcdDzWOtPpZQXeOnpAmc9FrMvdKwdKarDlJpXpSXnowcNcCMS_ZUZ8rYB9GV0j-hrppCLm75RqOG_KLimVhxYYqGOz0Mysm5l2Ob4G-yOiQ8dUQOWA3J5knWn2YwJH2oBJYCkVn0mE2OGW90SDAbSFGwmE?key=ianDbsjkc0RXj3caq9iwJw

Now, Click on Publish button confirm the JSON data and publish config.

AD_4nXf3akIlixjpIijHEfxIkLmIimfbgRBmcp85vlY3DIPU7NggL5qPauPZpRETsfTvc-fZOv8joAJfGTcvIHY0Y4fNxezzCG9Vkr2b1WklXV3Xh4bN8p3PJaTRFRS4mog57HrXj16chM3LpTCagp1P--tXjUiT?key=ianDbsjkc0RXj3caq9iwJw

AD_4nXfyqQ0zGyoGB_ELVXs98PsfaKK9hgZZYqmqVM4aMK3bDtembiuQvuJx-gIozUQQwZS82f0Qg-1RfppNXwRuA69tx6ODcsBf9bP_k0VjJ9Est0zd89jjCZvCX2Zc7KvS_oXMQn9uBZvqdWo_XFV0lEzMSUwG?key=ianDbsjkc0RXj3caq9iwJw

  • Fetch and Use JSON Data in Unity

Now that the JSON data is set up in Remote Config, Let's fetch and use it in Unity 3d game development.

Create RemoteConfigInitializer.cs script and add the below code to fetch JSON data from Remote Config.

ApplyRemoteSettings() in the ‘RemoteConfigInitializer’ script to fetch the JSON data from the gameConfig key which we set in the dashboard. ParseJSON() will parse the data from string and then we can access the remote config data.

AD_4nXcU5McXRqnosuV8CozIRqXaYadF4TuhZ6SU_TrTw-dXEbh_ieJozHL7xlsQHwO8pfDNDvzeW7A_5Xqnolc1ow_ded4rJbZ-jmruc4zi4Zut7dMwJasvWdc32wsdap6X9LNEjjHr6_KMzdE7ImCk3LQEcWIk?key=ianDbsjkc0RXj3caq9iwJw

Now, Attach this script to the GameObject in the scene. Click on the Play button in the editor game and check the console for the parsed JSON values.

Modify the JSON data in the Unity Dashboard, save, and publish it again. Re-run your game to see the changes take effect without redeploying your application.

AD_4nXffK4Lnct3WYTgMfM2JvSyK0e5SpijsQHWTgnRw6LBOM9qEQyDsn-8SXYFn807y8I54HYwFy6lAkwNtwCphZlp6YmCT-oM0qurgLP2QSxo_D7gEjQsY1dmmS6t5nMoKOtwOz3trUnfG9ib9ULlGtux-46E?key=ianDbsjkc0RXj3caq9iwJw

AD_4nXeOHBWe0wlsujNaYd4ZRqCu5q55I1xtqEElKNs1rZPvCQLTORVVf1DHAaCy5lPs92-pj2qXARwuP2gxXcB0PbbQSwnWjWP2t2epbqE1upYBGOCdg5JsGxxoKcOll6KYMXUsRxiT7wpkhAmx1Rt7tcF50tv5?key=ianDbsjkc0RXj3caq9iwJw`

  • Conclusion

Using Unity's Remote Config to manage JSON data allows for dynamic and flexible game updates. By following the steps outlined in this blog, you can easily set up, fetch, and use JSON data in your Unity project, enabling you to make real-time adjustments to your game's configuration without requiring a full update.

With this setup, you can experiment with game settings, conduct A/B tests, and tailor the gaming experience to your audience'