Config loading

Author: Fredrik Ludvigsen (Steinbitglis)

Description
Using the pattern means that you can have a global object, that is always loaded in playmode, but not otherwise.

You should also put your asset in PlayerSettings.preloadedAssets, to get the same behaviour in builds.

This is the best way to load global data, because they are loaded effectively, and before anything else.

PS: Using Resources.Load, you can obtain something similar, but much less performant, and more complex to set up.

Usage
- Put PlaymodeConfigLoader.cs in some editor folder (Assets/Scripts/Editor, Assets/Editor, etc.). - Put ConfigAsset.cs in any other folder. - Create your config asset (from the menu, Assets->Create->ConfigAsset). - Edit ConfigAsset.cs to suit your needs. - Edit PlaymodeConfigLoader.cs to suit your needs. (Adjust the guid, or hard code paths). - Populate the asset with data. - Use ConfigAsset.config from other scripts to access your config data :-)





Enjoy effortless config loading!