Super UI – Creating Enums According To Project

In SuperUI, enums can be created according to your project. For example, you need main, characters and market menus in your project. Then you create main, characters and market menu enums using with SuperUI EnumCreator editor. Let’s see how we can do this.

First, we are going to use simple code generation for generating PanelType enums. If you want to read an advanced topic about code generation in Unity, you can read this perfect article.

Let’s look at our variables in enum creator script:

  •  window : Enums creator editor window.
  • EnumsWindowRect : Enums creator window size.
  • scrollPosition : using for dragging the window.
  • enumsContainerPath : For now, we statically define menu container script directory. I am going to make this dynamic in the future.
  • enums : our current enums
  • currentEnumStringToAdd : Store last typed enum to add our enum list.

Creating the window

  • When we click the Tools/EnumCreator button, the creation of the window is started. In the Awake method of the enum creator window, the window is created and last enum types in the project are stored.

UI side

  • This is a simple GUI code for our enums creator. We can add, delete, move-up, mode-down an enum and save all enums we have in the creator window.

Saving Enums in a C# script

SuperUI panel type enums are contained in LB_EnumContainer. LB_EnumContainer is a C# script.

When we press the Save Enums button in our enums creator window, the enums are saved in the LB_EnumContainer. Unity compiles the LB_EnumContainer script and our enums are ready to use.

We create the following script with compiling the code.

 

Github link of SuperUI is here!