Editor API and Serialization

As the development of MIME//SCAPE continued, many of the programmers that worked on the project have shown a desire to create tools in order to allow for more in-depth iteration and testing on gameplay and performance. Furthermore, artits and level designers both required tools to help them create better content that the game needed.

Given the above reasons, one developed an Editor API that anyone can use in order to create their own Editor inside MIME//SCAPE's custom engine!

Developing an Editor API

Inspired by the Unity Engine's Editor API, the custom editor API uses an inheritance structure to allow the end-user to easily interact with the Editor, Engine and Dear Imgui APIs. Using Dear Imgui as part of the Editor API comes with the benifit of allowing people to look up documentation online on how to achieve certain things and even makes external tools compatible with the Editor API.

Now, other programmers can create and use their own editor extensions inside the engine with ease. However, a new problem was introduced.

Using custom editors

The problem now is that non-techincal users could not determine which editor would be open or closed. As such, a Command System was developed to allow programmers to assign different menu tabs to their editors, which the end-user could then determine to open or close.

This began with creating the database for creating the commands in the api using templates as a means to automate some of the process when a front-end programmer registers their editor extension.

The datastructure used to save the commands.

A code snippet that shows how templates can be used to automate some logic away from the end-user.

This comes with the added benifit of allowing programmers to add custom commands that do not create editors in the case of creating some form of cheats.

Overall, the user experience of using the editor has been massively improved as users can now open and close any editor window they want. However, Dear Imgui's serialization scheme does not support this inheritance structure that the Editor API has introduced, resulting in the user being unable to save their layout of windows upon a restart.

Serializing Layouts

The crux of the issue is that Dear Imgui creates instances of editor windows that are dependant on unique identifiers. These identifiers are based of the editor window's name which is determined by the user's Editor script.

To resolve this, the editor's name and initialization order is serialized in a json file which is used whenever the engine restarts or switches layout. Specifically, the json file contains an address to a layout’s corresponding .ini file, which contains the position and docking information of each ImGui element.

In order to use the data that was just saved in a json file, the system that manages the creation of editor instances was updated to add the extra support of creating instances of editors manually via code using the editor type’s name as its key.

With the above adjustments and fixes, a layout system was introduced that allows the end-user to freely load create layouts of different editors.

Next
Next

Recursive Scriptable Editor