Save Exercise

1_ScriptableVariable

You can set a random color to the player by clicking on the “Random Color” button on the bottom of the screen at runtime. Currently, the color is not saved. Can you find how to save the player color?

Solution 1: find the BindRendererColor.cs component on the prefab_player ->View.

Then, expand the Scriptable Variable, enable the “Saved” property and set the default color to white.

Solution 2: find the scriptable variable example_player_color and enable the “Saved” property.

Note: when you create a new scriptable variable type, you can override the Save and Load method, and have custom save/load for them using Player Prefs 😊. Check the ColorVariable or Vector2Variable to have a concrete example.

Last updated