World Settings

Description

This scene contains examples of how to have settings that persist between world sessions.

How it Works

There are three different scripts depending on your use case.

  • PersistentToggle - As the name suggests this script can persist the enabled state of objects using a key. Simply add the GameObjects you want to be toggled to the state of the persistent key, add a unique or already used key name. Then call the SetActive or SetInactive function on the PersistentToggle script using SendCustomEvent from buttons or other scripts to toggle it. Also has option for flipping so the selected objects are disabled when key is enabled and vice versa instead.

  • MultiStatesToggle - This is an example of having an array of objects where only one of them are active at once. To use simply add the different states GameObjects you want and then write down the key you want to use. Then you can switch states by calling Next or Previous via SendCustomEvent to the MultiStatesToggle script.

  • PersistentVolumeSlider - A script to save the volume of AudioSources. Simply add all the AudioSources you want to be controlled by this script to the array. Then add a key and add a slider from UI that you want to control this.

How to use this Example

Open the WorldSettings scene and then hit play and toggle the settings to your preferred state. Then stop the scene and play it again. Your settings should be remembered.

1 Like