{"id":89582,"date":"2021-01-19T15:58:21","date_gmt":"2021-01-19T15:58:21","guid":{"rendered":"https:\/\/www.red-gate.com\/simple-talk\/?p=89582"},"modified":"2022-04-24T20:58:56","modified_gmt":"2022-04-24T20:58:56","slug":"how-to-use-unitys-remote-config","status":"publish","type":"post","link":"https:\/\/www.red-gate.com\/simple-talk\/development\/dotnet-development\/how-to-use-unitys-remote-config\/","title":{"rendered":"How to use Unity&#8217;s Remote Config"},"content":{"rendered":"<p>Imagine you&#8217;ve spent much time, possibly years, into crafting your Unity app. The app then gets published, the launch is smooth, everything&#8217;s good. However, then some time passes, and you want to modify some small item in your app. Maybe it&#8217;s a game, and you want to change the base health of an enemy type, or it&#8217;s a business app, and you want to notify users of a handy new feature. One might expect the developer to open up their Unity project, whether at home or at a work PC, make the necessary tweaks, and push these changes to their app. However, suppose instead you&#8217;re out of town, away from your work PC, and the changes required need to happen as soon as possible. What do you do? One option available is Unity&#8217;s Remote Config, a feature that lets you make changes to an app from anywhere in the world so long as you have a web browser and can open your Unity Dashboard.<\/p>\n<p>Unity\u2019s Remote Config lets you change your app remotely and in real-time. It&#8217;s especially useful for fine-tuning your software attributes without needing to redeploy it with every change. You can also use Remote Config for live events by enabling holiday themed content or to unlock a previously created feature. Note that Remote Config is not meant to be used for creating entirely new content for your app, but rather modifying or unlocking what is already in the app. While actively developing the application, Remote Config can be used to iterate on the program without needing to modify the code itself. To demonstrate this feature, a simple project will be put together that allows you to change a bool, string, int, and even JSON data from within the Unity Dashboard. Changes made in the dashboard will then be reflected within the app itself.<\/p>\n<h2>Project Setup<\/h2>\n<p>This example assumes that Unity 2020 will be used for the project. However, the 2019 version will work just as well. Select the default 3D template, give your project a name, and set its location. Then click the <em>Create <\/em>button.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-89583\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/01\/word-image-18.jpeg\" alt=\"Creating a new project.\" width=\"896\" height=\"484\" \/><strong>Figure 1: Creating a new project<\/strong><\/p>\n<p>To utilize Unity\u2019s Remote Config, you must set up Unity services and acquire a project ID. To do this, navigate to the <em>Edit <\/em>top menu and select <em>Project Settings<\/em>. From there, select the <em>Services <\/em>option. Please note that you may need to create a Unity account and log into it at this point. You&#8217;ll then be asked to select an organization. Once you do, you may then click the <em>Create project ID <\/em>button. Unity will then automatically assign your project an ID.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-89584\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/01\/word-image-19.jpeg\" alt=\"Setting up Unity Services\" width=\"762\" height=\"446\" \/><\/p>\n<p><strong>Figure 2: Setting up Unity Services<\/strong><\/p>\n<p>Next, you need to install the Remote Config package from Unity. Doing this requires navigating to the <em>Package Manager<\/em>, which is found in the top menu under <em>Window-&gt;Package Manager<\/em>. At first, the <em>Package Manager <\/em>will only show the packages currently installed in your project. To view all available packages, select the dropdown that currently shows <em>Packages: In Project <\/em>and choose <em>Unity Registry<\/em>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-89585\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/01\/word-image-20.jpeg\" alt=\"Accessing packages in the Unity Registry\" width=\"315\" height=\"214\" \/><\/p>\n<p><strong>Figure 3: Accessing packages in the Unity Registry<\/strong><\/p>\n<p>Scroll down until you find <em>Remote Config<\/em>, then click the <em>Install <\/em>button to add Remote Config to your project.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-89586\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/01\/word-image-21.jpeg\" alt=\"Installing the Remote Config package\" width=\"976\" height=\"503\" \/><strong>Figure 4: Installing the Remote Config package<\/strong><\/p>\n<p>To better see the effects of Remote Config, you&#8217;ll need a small handful of objects to change within your app. Start by creating a simple cube by going to the <em>Hierarchy <\/em>window and selecting the <em>+ <\/em>button, then choosing <em>3D Object-&gt;Cube<\/em>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-89587\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/01\/word-image-22.jpeg\" alt=\"Creating a new object\" width=\"504\" height=\"500\" \/><\/p>\n<p><strong>Figure 5: Creating a new object<\/strong><\/p>\n<p>By default, the object should be placed with location coordinates of 0, 0, 0 with no rotation and a scale of one. You can leave this object as is, but if you want or need to change it, go into the <em>Inspector <\/em>window and change the values seen in the <em>Transform <\/em>component. Right after that, using the same object creation menu, create a UI with text. Set its position to be 0, 150 and give it a width of 250. It also looks nice to give the text center alignment and some default text. Finally, give it a unique name to help identify it easier.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-89588\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/01\/word-image-23.jpeg\" alt=\"Giving object a name, setting position and size, creating default text, and alignment\" width=\"582\" height=\"660\" \/><\/p>\n<p><strong>Figure 6: Giving object a name, setting position and size, creating default text, and alignment<\/strong><\/p>\n<p>Duplicate this text with Ctrl + D and move the copy a little lower down (this example changed the Y position to 100). This text will display a lucky number, which it will get from the Remote Config server. Change the object&#8217;s name and default text accordingly.<\/p>\n<p>Finally, create the script needed to get the project running. Inside your <em>Assets <\/em>window, right-click and select <em>Create-&gt;C# Script<\/em>. The script in the example will be called <em>GetConfig<\/em>. With this, all the assets are in place, but Remote Config itself still needs a little more setup before you begin the coding process.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-89589\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/01\/word-image-24.jpeg\" alt=\"Creating a new C# script\" width=\"586\" height=\"742\" \/><\/p>\n<p><strong>Figure 7: Creating a new C# script<\/strong><\/p>\n<p><strong><em>Preparing Remote Config<\/em><\/strong><\/p>\n<p>From the top menu, select <em>Window-&gt;Remote Config<\/em>. Once you do so, you&#8217;ll be greeted with a window where you can create settings and push settings from Unity to the Remote Config server and vice versa. First, you&#8217;ll need some environments to work in. You should be able to pull in the two default environments currently sitting in the server. Doing this is as simple as clicking the <em>Pull <\/em>button in the top right. If these environments don&#8217;t appear, wait a few minutes for Unity to automatically create these in the server, then try pulling again. There&#8217;s also the option of creating your own environment if you are having trouble pulling the default environments. The <em>Create <\/em>button at the top of the window will allow you to do this. If you aren&#8217;t able to create an environment within the Remote Config window or can&#8217;t find the <em>Create <\/em>button, try updating to a preview version of Remote Config. Directions on how to do this are listed in the JSON portion of this article. . . As far as what environment to use, , it&#8217;s recommended to use or create the <em>Development <\/em>environment while actively developing the app.<\/p>\n<p>Now is the time to create some settings that will be used in the project and can change from within your Unity Dashboard. Click the <em>Add Settings <\/em>button located at the bottom. A new setting is created with the option to give it a name and choose a type. This project will focus on editing a bool, string, and int value. After choosing a type, you&#8217;ll then be asked for a value. Give the setting a value of your choosing.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-89590\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/01\/word-image-25.jpeg\" alt=\"The Remote Config window with settings\" width=\"799\" height=\"557\" \/><\/p>\n<p><strong>Figure 8: The Remote Config window with settings<\/strong><\/p>\n<p>In order to properly utilize Remote Config, you&#8217;ll need to push these settings out to the server. Click the <em>Push <\/em>button to achieve this. Once you&#8217;ve done so, you&#8217;ll have successfully stored these values in the Remote Config server to be used in your project. In the future, if you ever needed to get any new or updated settings made in the Unity Dashboard, you would click the <em>Pull <\/em>button. So, <em>Push <\/em>any settings you make in the editor, <em>Pull <\/em>any made in the dashboard.<\/p>\n<p>Since this app wants to use settings in the <em>Development <\/em>environment within the Remote Config server, you&#8217;ll need to go to your project&#8217;s <em>Build Settings <\/em>in the<em> File <\/em>menu and check the box that says <em>Development Build<\/em>. This change can be made by first going to the top menu, choosing <em>File<\/em>, then <em>Build Settings<\/em>, then ticking <em>Development Build<\/em>. Now, whenever you run a .exe build of the app, it will get the settings seen in the <em>Development <\/em>environment. When releasing an app, you would want to uncheck <em>Development Build <\/em>and have your settings created and ready within the <em>Release <\/em>environment.<\/p>\n<h2>GetConfig Code<\/h2>\n<p>With everything set up, open the <em>GetConfig <\/em>script by double-clicking it in the <em>Assets <\/em>window. Once Visual Studio opens, the first thing to do is add <code>using Unity.RemoteConfig<\/code> and <code>using UnityEngine.UI <\/code>to the top of the script. Once that&#8217;s done, add the following to the class:<\/p>\n<pre class=\"lang:c# theme:vs2012\">public struct userAttributes { }\r\npublic struct appAttributes { }\r\nprivate bool isBlue;\r\nprivate string message;\r\nprivate int number;\r\n[SerializeField] private Renderer rend;\r\n[SerializeField] private Text messageText;\r\n[SerializeField] private Text numberText;<\/pre>\n<p>For now, these two structs are not going to do anything. They will simply be passed into a method later to tell Unity to just use the default Remote Config settings. If you wanted to add custom attributes like a player name or skill level, this is where you would set that up. From there, your custom attributes can be used to only apply settings to users with certain attributes. However, for this project, the code will be kept simpler and focus on important aspects of Unity\u2019s Remote Config.<\/p>\n<p>Three private variables <code>isBlue<\/code><em>, <\/em><code>message<\/code><em>, <\/em>and <code>number<\/code> will all be changed based on the values stored within your Remote Config settings. These values will be displayed using the cube object and the UI. All remaining variables are for changing properties of object components and the UI text created earlier. The <code>SerializeField<\/code> tag makes these otherwise private variables visible to the editor for editing.<\/p>\n<p>The first thing to do is to let Unity know to call the <code>SetValues<\/code> function once Remote Config has finished retrieving data. <code>SetValues<\/code> will be created in a moment. After that, it then works on retrieving your currently stored configuration. Notice that the <code>userAttributes<\/code> and <code>appAttributes<\/code> types are passed into the <code>FetchConfigs<\/code> method, followed by creating new instances of those structs. All this is saying is that the project will use the default settings currently stored in Remote Config. This will all happen within the <code>Awake<\/code> function which replaces the <code>Start<\/code> function. Unity&#8217;s <code>Awake<\/code> function grants a little more safety when using Remote Config.<\/p>\n<pre class=\"lang:c# theme:vs2012\">private void Awake()\r\n{\r\n\tConfigManager.FetchCompleted += SetValues;\r\n\tConfigManager.FetchConfigs&lt;userAttributes, appAttributes&gt;\r\n             (new userAttributes(), new appAttributes());\r\n}<\/pre>\n<p>Next comes the <code>Update<\/code> function, which will have been created automatically when creating the script. Very little Remote Config work is being done here. This function will let you fetch configurations again whenever the left mouse button is clicked and give the app a way to close itself using the escape key. The code will be especially useful in demonstrating how you can make changes to your app from the Unity dashboard seamlessly while it is running.<\/p>\n<pre class=\"lang:c# theme:vs2012\">private void Update()\r\n{\r\n\tif (Input.GetMouseButtonDown(0))\r\n\t\tConfigManager.FetchConfigs&lt;userAttributes, appAttributes&gt;(\r\n                      new userAttributes(), new appAttributes());\r\n\tif (Input.GetKeyDown(KeyCode.Escape))\r\n\t\tApplication.Quit();\r\n}<\/pre>\n<p>Now is where the <code>SetValues<\/code> method comes in and is where the magic happens. Using Remote Config, you&#8217;ll change the values of <code>isBlue<\/code><em>, <\/em><code>message<\/code><em>, <\/em>and <code>number<\/code> then use those values to change different parts of the app. The cube object will change color based on the value of <code>isBlue<\/code>, and the values of <code>message<\/code> and <code>number<\/code> will be shown in the app&#8217;s UI.<\/p>\n<pre class=\"lang:c# theme:vs2012\">void SetValues(ConfigResponse response)\r\n{\r\n\tisBlue = ConfigManager.appConfig.GetBool(\"IsBlue\");\r\n     message = ConfigManager.appConfig.GetString(\"MessageOfTheDay\");\r\n     number = ConfigManager.appConfig.GetInt(\"LuckyNumber\");\r\n\t\/\/ apply values pulled from config\r\n\tif (isBlue)\r\n\t\trend.material.color = new Color(0, 0, 1);\r\n\telse\r\n\t\trend.material.color = new Color(1, 0, 0);\r\n\tmessageText.text = message;\r\n\tnumberText.text = \"Lucky Number is: \" + number.ToString();\r\n}<\/pre>\n<p>The last job to be done is to make sure <code>SetValues<\/code> won&#8217;t be called when the object is destroyed. Earlier in the <code>Awake<\/code> function the script tells Unity to call <code>SetValues<\/code> anytime Remote Config has finished gathering configurations. However, if the object using Remote Config&#8217;s data is destroyed, you wouldn&#8217;t want that function being called. So, as a precaution, <code>OnDestroy<\/code> is used to remove the callback function, assuring that <code>SetValues<\/code> is not called when it is not needed.<\/p>\n<pre class=\"lang:c# theme:vs2012\">private void OnDestroy()\r\n{\r\n\tConfigManager.FetchCompleted -= SetValues;\r\n}<\/pre>\n<p>With all the code in place, save the script and return to the Unity editor to perform some finishing touches and run the project.<\/p>\n<h2>Testing the App<\/h2>\n<p>The first thing to do is attach the <em>GetConfig <\/em>script to the <em>Cube <\/em>object. Select the object in the <em>Hierarchy <\/em>window and then click and drag the script into the <em>Inspector <\/em>window.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-89591\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/01\/word-image-26.jpeg\" alt=\"Adding the GetConfig script component\" width=\"897\" height=\"875\" \/><strong>Figure 9: Adding the <em>GetConfig <\/em>script component<\/strong><\/p>\n<p>Now drag the object&#8217;s <em>Mesh Renderer <\/em>component into the <em>Rend <\/em>field, thereby allowing the program to change the cube&#8217;s color.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-89592\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/01\/word-image-27.jpeg\" alt=\"Setting Rend to be the object's Mesh Renderer component\" width=\"588\" height=\"767\" \/><\/p>\n<p><strong>Figure 10: Setting <em>Rend <\/em>to be the object&#8217;s <em>Mesh Renderer <\/em>component<\/strong><\/p>\n<p>Finally, expand the <em>Canvas <\/em>object to find your two text objects. Drag them into the corresponding fields in the <em>GetConfig <\/em>component. Before selecting the two text objects, you may need to lock the inspector by clicking the padlock icon at the top.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-89593\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/01\/word-image-28.jpeg\" alt=\"Setting Rend to be the object's Mesh Renderer component\" width=\"898\" height=\"883\" \/><strong>Figure 11: Setting the text fields<\/strong><\/p>\n<p>You&#8217;re all set! Run the program in the editor using the play button at the top and notice how the text and cube color changes to reflect what&#8217;s currently in Remote Config. If you&#8217;re having trouble seeing the changes, then here&#8217;s a few things you can try:<\/p>\n<ul>\n<li>Make sure you&#8217;re using the correct names of your settings in the <em>GetConfig <\/em>script.<\/li>\n<li>Make sure each text object is assigned to the correct field in the object&#8217;s <em>GetConfig <\/em>component.<\/li>\n<li>Close and reopen Unity.<\/li>\n<li>Push and\/or pull your Remote Config settings in the Remote Config window.<\/li>\n<li>Change the default environment in the Unity dashboard and pull again. Read on for more information on using the dashboard for Remote Config.<\/li>\n<li>Create a brand new environment and set it as the default.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-89594\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/01\/word-image-29.jpeg\" alt=\"First run of the app\" width=\"888\" height=\"394\" \/><strong>Figure 12: First run of the app<\/strong><\/p>\n<p>Now, let&#8217;s change these objects from the Unity dashboard. To open the dashboard, locate the <em>Services <\/em>window under <em>Window -&gt; General<\/em> and click on the link to the dashboard. You will likely need to log in to your Unity account at this stage. Once logged in, you should be inside the dashboard for the project you have open. From there, open the menu (from the top left corner of the browser) and find Remote Config, located towards the bottom. From within Remote Config&#8217;s sub menu, choose <em>Environments<\/em>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-89595\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/01\/word-image-30.jpeg\" alt=\"Remote Config screen, seen in browser\" width=\"1183\" height=\"507\" \/><strong>Figure 13: Remote Config screen, seen in browser<\/strong><\/p>\n<p>Here, you can change the default environment (make sure it&#8217;s set to <em>Development<\/em>), edit other environments, and create new ones. Click <em>View Configs\/Rules <\/em>for the <em>Development <\/em>environment, then choose <em>Default Config<\/em>. Your settings will all appear, and you can change them as you wish, add new settings, and delete any you don&#8217;t want anymore. Try setting <em>IsBlue <\/em>to true and changing the <em>LuckyNumber <\/em>and <em>MessageOfTheDay <\/em>values.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-89596\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/01\/word-image-31.jpeg\" alt=\"Editing settings\" width=\"1122\" height=\"438\" \/><strong>Figure 14: Editing settings<\/strong><\/p>\n<p>When you&#8217;re finished, click <em>Save <\/em>then run your app again. Your changes should be made apparent in the app.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-89597\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/01\/word-image-32.jpeg\" alt=\"App reflects changes made in Remote Config environment\" width=\"890\" height=\"395\" \/><strong>Figure 15: App reflects changes made in Remote Config environment<\/strong><\/p>\n<p>What&#8217;s more, you can see these changes occur in real-time too. With the app running, make another change in the dashboard, save it, then go back to the app and click anywhere on the screen. You should see the changes update after the mouse click. If you ever wanted to test this out on other people&#8217;s devices, you would need to build an exe using the <em>Build Settings <\/em>window, ensuring that <em>Development Build <\/em>is checked if the app is currently in development. If it&#8217;s not, leave it unchecked and make sure the appropriate Remote Config environment is set as the default one.<\/p>\n<h2>JSON Functionality<\/h2>\n<p>The project demonstrates the ability to modify variables without needing to open the Unity editor, and the variable types chosen are likely the most common ones you&#8217;ll use. For all intents and purposes, the project is complete. But when looking at the Unity Dashboard, you&#8217;ll notice that, along with floats and longs, another data type can be utilized. One of the more exciting options is the ability to utilize JSON within the app and changing that JSON as needed using Remote Config. However, as of this writing, it must be noted that Remote Config&#8217;s JSON functionality is still currently in active development and is not complete. That said, developers can still use JSON in their Remote Config projects if they install a preview version of the Remote Config package.<\/p>\n<p>To start, return to the <em>Package Manager <\/em>window and find the <em>Remote Config <\/em>package. Click the arrow next to it to expand the version options available to you. Find version 2.0.1, then click the <em>Update <\/em>button.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-89598\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/01\/word-image-33.jpeg\" alt=\"Updating Remote Config to preview version\" width=\"967\" height=\"503\" \/><strong>Figure 16: Updating Remote Config to preview version<\/strong><\/p>\n<p>Next, reopen the <em>Remote Config <\/em>window. You may need to pull your settings again if the window is empty. Once it&#8217;s filled, change the environment to <em>Development<\/em> and create a new setting, giving it a name and the JSON type.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-89599\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/01\/word-image-34.jpeg\" alt=\"Creating a JSON setting\" width=\"799\" height=\"557\" \/><\/p>\n<p><strong>Figure 17: Creating a JSON setting<\/strong><\/p>\n<p>To change the JSON code, click on the edit button. A JSON editor will appear, allowing you to enter any of the JSON you wish. For this example, the following code will be used:<\/p>\n<pre class=\"lang:c# theme:vs2012\">{\r\n  \"rotate_X\": 10,\r\n  \"rotate_Y\": 35,\r\n  \"rotate_Z\": 10\r\n}<\/pre>\n<p>Make sure to push this to the Remote Config server, then reopen the <em>GetConfig <\/em>script to utilize the newly created JSON.<\/p>\n<h2>Using JSON in Code<\/h2>\n<p>In order to use your newly created JSON, you&#8217;ll need to create a serializable class that can hold the data. The intent of the code is to modify the rotation of the cube object, which would be a property found within its <em>Transform <\/em>component. So, you&#8217;ll need to set up the class accordingly and get that component too. After that, a little code is added to <code>SetValues<\/code> and the JSON functionality is all set.<\/p>\n<p>The serializable class is a good place to start. It can be placed anywhere so long as it&#8217;s outside the main class. As for the code, it consists of the following:<\/p>\n<pre class=\"lang:c# theme:vs2012\">[System.Serializable]\r\npublic class TransformInfo\r\n{\r\n\tpublic float rotate_X = 0f;\r\n\tpublic float rotate_Y = 0f;\r\n\tpublic float rotate_Z = 0f;\r\n}<\/pre>\n<p>Two very important things to note about this. First, it&#8217;s integral that the class has the <code>System<\/code><em>.<\/em><code>Serializable<\/code> tag attached to it. Else, the JSON code won&#8217;t be able to write to the class at all. Second, make sure the names of the variables match what&#8217;s inside your JSON code, capitalization and all. This is generally true of programming in general, but it&#8217;s worth reiterating here to be safe.<\/p>\n<p>Returning to the original <code>GetConfig<\/code> class, the project needs to be able to change the cube&#8217;s <em>Transform <\/em>component, and more specifically the rotation data. To allow this, create a new variable:<\/p>\n<pre class=\"theme:vs2012 lang:c# decode:true \">[SerializeField] private Transform tf;<\/pre>\n<p>The final step has you adding to the <code>SetValues<\/code> method. Like the other settings in Remote Config, you need to instruct Unity on how to use the newly retrieved JSON.<\/p>\n<pre class=\"lang:c# theme:vs2012\">TransformInfo tInfo = new TransformInfo();\r\nvar jsonString = ConfigManager.appConfig.GetJson(\"JSONTest\");\r\nJsonUtility.FromJsonOverwrite(jsonString, tInfo);\r\ntf.rotation = Quaternion.Euler(tInfo.rotate_X, \r\n      tInfo.rotate_Y, tInfo.rotate_Z);<\/pre>\n<p>First, a new <code>TransformInfo<\/code> object named <code>tInfo<\/code> will be created, followed by collecting the JSON code currently stored in the Remote Config server. Then we use the <code>JsonUtility<\/code> Unity class to, as the method name implies, rewrite the values of <code>tInfo's<\/code> variables according to what is in your JSON. After that, this object&#8217;s Transform component&#8217;s rotation is changed to whatever is now being held inside the <code>tInfo<\/code> object.<\/p>\n<p>Be sure to save the script again, then return to the Unity editor to test the project.<\/p>\n<h2>Testing the JSON<\/h2>\n<p>Just before running the program, make sure the <em>GetConfig <\/em>component on the <em>Cube <\/em>object has the <em>tf <\/em>field filled. Similar to the <em>Mesh Renderer <\/em>component from earlier, all this takes is dragging the <em>Transform <\/em>component in the <em>Inspector <\/em>window into the field. Once that&#8217;s ready, run the project again. The cube should rotate itself according to what&#8217;s inside your JSON code. Be sure to go back to the dashboard, edit the rotation values, then left-click back in the Unity app to see an immediate change in the object&#8217;s rotation.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-89600\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/01\/word-image-35.jpeg\" alt=\"App utilizing JSON stored within Remote Config setting\" width=\"890\" height=\"396\" \/><strong>Figure 18: App utilizing JSON stored within Remote Config setting<\/strong><\/p>\n<h2>Using Unity\u2019s Remote Config<\/h2>\n<p>The ability to change your app from anywhere cannot be overstated. Even if you&#8217;re not the type who often travels, having this option to make quick and easy changes to your app brings the benefit of updating an app without having to go through the process of rebuilding it and sending out a traditional patch. Alongside making small, individual changes to an app, Remote Config also allows you to create rules, which are perfect for limited-time events. Set your dates and what settings will be affected, and your app will adjust itself per your Remote Config rule. For more information on Remote Config, check out Unity&#8217;s official documentation, found <a href=\"https:\/\/docs.unity3d.com\/Packages\/com.unity.remote-config@2.0\/manual\/index.html\">here<\/a>.<\/p>\n<p><em>If you liked this article, you might also like<\/em>\u00a0<a href=\"https:\/\/www.red-gate.com\/simple-talk\/dotnet\/c-programming\/how-to-create-a-settings-menu-in-unity\/\">How to Create a Settings Menu in Unity &#8211; Simple Talk (red-gate.com)<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>You can use Unity\u2019s Remote Config utility to update settings for users. Lance Talbert walks you through using the utility including a JSON example.&hellip;<\/p>\n","protected":false},"author":317499,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[143538],"tags":[136044,5134,136043],"coauthors":[52549],"class_list":["post-89582","post","type-post","status-publish","format-standard","hentry","category-dotnet-development","tag-remote-config","tag-sql-prompt","tag-unity-configuration"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/89582","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/users\/317499"}],"replies":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/comments?post=89582"}],"version-history":[{"count":7,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/89582\/revisions"}],"predecessor-version":[{"id":89607,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/89582\/revisions\/89607"}],"wp:attachment":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media?parent=89582"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/categories?post=89582"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/tags?post=89582"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/coauthors?post=89582"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}