To make it easier for a developer to edit the CP Social settings I used a ScriptableObject to save CP Social’s settings. When using a ScriptableObject Unity creates a default editor to edit it’s data, shown in the image below.
After using this editor for a while I really wanted a way to edit the data easier, so I created a custom editor for the settings object. This was done using editor scripting.
The first version of the configurator was created after about 2 weeks working with the default Unity editor. This default editor worked pretty well but didn’t give a very clear view of all the data in the settings object. It had a lot of data behind a lot of dropdown menus. The focus for the configurator would be creating an easy to manage UI that a developer would understand without having to look at the documentation to manage atleast the achievements.
The biggest problem of the first version of the configurator was speed. When I made it I used pre-processor directives to make parts of the logic inside the CP Social settings object accessible when the editor was opened. As soon as the configurator was opened it caused Unity to restructure and recompile some assemblies causing the editor and visual studio to lock up for 10-30 seconds, in which the developer couldn’t do anything.
Furthermore the configurator used a lot of tabs in it’s UI which as I said earlier is one of the thing I didn’t want in the editor. I didn’t want the data to be obstructed by tabs. I wanted it to be easily accessible.
Also seen as this configurator was one of the first real editor scripting I did in Unity, it was very buggy.
Example: In the screenshot below on the left you can see what a single unlock achievement would look like in the configurator. On the right is what an incremental achievement looked like in the configurator.
Do you the a difference? Yes there are three more input fields in the editor, but what you might not have seen (because they are missing), the ‘Confirm’ and ‘Cancel’ buttons are missing. These buttons just disappeared as soon as you set you converted an achievement to incremental.
This was one of the many bugs the first version of the configurator had.
All these reasons combined let me to creating a complete new version of the configurator that had to solve all the issue I had with the default editor and configurator V1.
Version two of the configurator had to solve all issues I had with the first version. I set some requirements for the second version so that I wouldn’t run into the same issue as I had with version 1.
Version 2 requirements:
- Fast, no locking up when opening
- Show all data in a single overview (not tabs!)
- Have the same functionalities as version 1
- No usage of pre-processor directives
- Easy to use
In short here is what version 2 looks like
The second version of the configurator improved on all aspects from the first version. As you can see in the image above, all data is visible on first sight. All tabs are gone, the only extra windows that are still present are the achievement edit windows.
The usage of SerializedObjects solved the biggest issue of the configurator begin slow. This is also the preferred way of creating custom editors in Unity. But at the time when I created V1 of the configurator I didn’t know how to use these SerializedObjects correctly.