Quick Singleton Scriptableobject in Unity - GameConfig

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

This is a great way to use ScriptableObjects since it looks like the information is static, however for others who want to make a ScriptableObject Game Settings system, it is important to know that in Unity game builds, ScriptableObjects reset to their default values when the game is closed and reopened. Does not mean you can not use them for game settings, but you will just need a way to save and load the settings when the game is opened.

ImmortalTimothyM
Автор

Useful for set object settings. Like ability stats/properties. In short treating it like a database of values or types etc. However if you're saving actual data. Scriptable objects are no good, the data is only persistent during play. You'll have to write your own save system. I recently had to write my own for option settings to allow for custom keybinds etc.

ScottxProductions
Автор

scriptable objects are the best!! I use them for everything from FSMs to power ups/spells to inventory items. Super powerful tool, and even though they get tons of praise I still think they're underrated lol

GlasTaibhse
Автор

Thanks Jason!
It's a pattern I often use, but just needed a refresher since it's been a while.

calccalccalc
Автор

this is genius lvl !
it smells like singleton but without all the bad stuff that comes with it.

etistyle
Автор

Im curious the advantage of it being a singleton? as a scriptable object will be accessible anywhere in the project as well.

simonnordon
Автор

You do a null check in the getter? Can you do this on startup or something similar instead of doing the if check every time you access the instance? Is there a way to do that in scriptable objects?

TheBluffStudios
Автор

I am curious, would `ScriptableSingleton<T0>` be better choice? It seems similar.
Thanks a lot for useful videos on code architecture ❤

sujyotraut.gamedev
Автор

What's the benefit of using a ScriptableObject here over a static class for storing data?

FileThrten
Автор

Hmm thought you can’t update variables of scriptable objects outside of the editor ( builds) . Do static variables ( cached instance ) get around this or does this only work in a build by always seeing it’s null and manually loading it from resources each time ( which would be terrible for perf) ?

Havie
join shbcf.ru