#Non-Versioning Debug Value of ScriptableObject
1 messages · Page 1 of 1 (latest)
What if you just don't serialize these debug values?
If the value needs to be serialized, but shouldn't be version-controlled, then yeah, you need a separate asset
note that you can often get away without actually serializing something – as long as the value doesn't need to survive a reload from disk
a custom inspector can display these non-serialized values
(the undo system won't know about them)
I need to serialize them because I don't want to set them again and again each time I click play.
Can you explain what kind of data this is exactly?
Boolean, Integer, Asset Reference, Prefab Reference, basically every value I need to override in debug.
Exemple : set a specific boss pattern to test
It does sound like you should just swap to a different SO when debugging
That's where SO's shine, easily swapping references/configs
Exactly. Easy to have 2 references and you can pick based on DEBUG being defined
You could also have a static method that "resolves" an asset reference into another asset reference based on whether you're in debug mode
you'd configure it with pairs of assets
so if you give it a boss definition, it hands you either:
- the same definition
- a replacement
This would avoid touching your real game data at all
You could use the [Conditional] attribute so that it's completely impossible to even try to do a swap outside of the editor/a debug build, too
BossSpec spec;
void StartBoss() {
AssetReplacer.Resolve(ref spec);
spec.DoSomethingIDK();
}
the Resolve method would do a switcheroo on you