use scriptable objects, they're very easy to use just make one class per data type like this:
[CreateAssetMenu(fileName = "WeaponConfig", menuName = "Data/WeaponConfig", order = 1)]
public class WeaponConfig: ScriptableObject
{
public string displayName;
public float damage;
}
create your data objects in say Resources/Data/Weapons right click in the project panel and tap Data/WeaponConfig, name it something gamey then load them all on game startup, something like this:
Dictionary<string, WeaponConfig> weaponConfigs;
..
Load(out weaponConfigs, "Data/Weapons");
..
void Load<T>(out Dictionary<string, T> dest, string path) where T : ScriptableObject
{
var configs = Resources.LoadAll<T>(path);
dest = new Dictionary<string, T>();
foreach (var config in configs)
{
dest[config.name] = config;
}
}
1
u/LargeLaser 18d ago
use scriptable objects, they're very easy to use
just make one class per data type like this:
create your data objects in say Resources/Data/Weapons
right click in the project panel and tap Data/WeaponConfig, name it something gamey
then load them all on game startup, something like this:
then do something like
or whatever the object is called
good luck!