[SOLVED] Equivalent to Godot's Resource or Unity's ScriptableObject?

Basically, I need a way to create an asset that can hold both data and some code (mostly getters). A dedicated Actor with a script to represent this data would be overkill. I need something like Resources or ScriptableObjects.

Does Flax have something like this? (JSON will not work since it’s a data-only format)

You can use a custom JSON asset to hold code and data. It is ultimately just a class. When you instance your assets you can run functions and access data. I would say that scriptable objects and JSON assets are pretty much the same thing. Why do they not work for you?

1 Like

I didn’t realize you could run code in the instanced assets… I never tried. I guess the fact that they’re JSON files led me to believe that they’re data only. I should have done more research before asking. (According to my own advice.)

Thanks. Marking as solved in case anyone has this question in the future.

Yeah once you instance the asset and cast it to the type that the asset is pulling from, then you can use it like a normal c# class.

1 Like

There doesn’t seem to be an option to create JSON assets anymore?

image

1 Like

It should be back on master branch. For now you can use the [ContentContextMenu()] attribute to expose your class to that menu.

Ah, thanks.