Home > Blockchain >  Scriptable Object not Change when running
Scriptable Object not Change when running

Time:12-07

I am currently using Unity 2021.351f1 version. I often use scriptable objects in my database. However, scriptable objects do not change at runtime. If I check has scriptable object in inspector, I can change them. Is this Unity's error? Or can Scriptable Object store only static data? How to store dynamic data in Scriptable Object.

CodePudding user response:

SOs are mainly used for storing static data. Dynamic data should be handled either in functions from SOs (there is an extension paradigm where polymorphism is slightly shifted from the normal convention and all modular code would be ran in a distinct SO - which would not be the one handling static data) or in Components (rather MonoBehaviors, but I was trying to capture all cases).

If you have a DB, then dynamic data can be accessed from the DB. Storing it in memory would make access a lot faster but would use up more memory. If there's only certain data that's needed, it should be done on demand or use some precaching techniques (such as loading them on events - think of loading a match up, precaching would be done while all players set up their inventory; at that point your map should be precached and before the actual match starts, you could precache the inventory items - this is an example, feel free to extrapolate, but I wanted to give you an idea how game events can help in this).

SOs are neither components, neither in-game objects that can represent enemies, weapons, objectives and so on. What they can do, is store data about items, enemies, weapons, objectives. Static data is also encouraged to be processed via prefabs (but that is another use case). You can also use non-vital prefabs for saving internal objects (think - audio mixer, playlists, audio snapshots etc.).

Your question is quite vague, so I am trying to think of most of the scenarios in U3D to cover it.

  • Related