DataAsset
August 15, 2022

In GDScript we can export properties. Or, in other words, expose them. With this we can edit their values through specialized editors within the Inspector panel.

Depending on the needs we can create a script derived (extends) from Resource meant to hold data, making those editable by exposing the relevant properties. In fact I have done something way more elaborate to hold databases, including some relational data (that is, tables that can reference other tables). This can be found in the Database Addon. Yet, sometimes all we want is an asset holding some data. No need for database tables or the likes.

As an example of this "simplified data", in a project I wanted the possibility to change the "skin" of the shown objects, which I called "theme" in the game itself. In order to "describe" each theme I created a resource script containing the required properties, like theme name, list of textures and so on. Then, for each theme, I had to create an instance of this resource.

When attempting to edit properties like that, there is a big limitation: We can't export custom resource types. Besides that, array editing is rather clunky. To solve that an editor plugin is required. And for this I bring the DataAsset plugin. Bellow an array of custom scripted resources is being rearranged:

Introduction
Previous1234567
8
910Next