The simplest way is to store data in the scriptable objects. It's an asset, that is stored in your project folder, that you create. You can then access it via direct reference on a game object, or load it from resources, or whatever you like. It's the basic way to go around stats and other game settings
unity's usual move for that kind of data is ScriptableObjects. make a script with CreateAssetMenu, put your stats as fields on it, then right click in the Project window and create assets you can drag onto whatever needs them. that keeps design data as files instead of hunting through scenes. for stuff that changes while playing (inventory, unlocks) people often use a plain C# class plus JsonUtility or a small save setup, and keep ScriptableObjects for the static design data. empty scene objects with public fields are fine for a prototype but get messy once you have more than one scene
no rush on JsonUtility, ScriptableObjects alone will get you really far. come back to saving once you actually need it, it's only a few lines when you get there. good luck!
2
u/Turbulent-Syrup3500 18d ago
The simplest way is to store data in the scriptable objects. It's an asset, that is stored in your project folder, that you create. You can then access it via direct reference on a game object, or load it from resources, or whatever you like. It's the basic way to go around stats and other game settings
2
u/johnv_dev 18d ago
unity's usual move for that kind of data is ScriptableObjects. make a script with CreateAssetMenu, put your stats as fields on it, then right click in the Project window and create assets you can drag onto whatever needs them. that keeps design data as files instead of hunting through scenes. for stuff that changes while playing (inventory, unlocks) people often use a plain C# class plus JsonUtility or a small save setup, and keep ScriptableObjects for the static design data. empty scene objects with public fields are fine for a prototype but get messy once you have more than one scene
1
u/Arrow__7 18d ago
Hey everyone, I'm looking for developers who use the Unity engine and have assets in the Unity Store. I need them.