To create an extensible class-based code architecture to manage complex IMGUIs, follow these steps:
- First let's create an interface, that is, a template script-class that defines a method all implementing-classes must have. Create a folder Editor. Inside that create a folder MyGUI. Inside that create a new C# script-class named IMyGUI containing the following:
public interface IMyGUI { void OnGUI(); }
- Now, let's define a FlexibleSpace class for our GUI library. Create a C# script class named MyGUIFlexibleSpace containing the following:
using UnityEngine; public class MyGUIFlexibleSpace : IMyGUI { public void OnGUI() { GUILayout.FlexibleSpace(); } }
- Now, we'll create a button class. Create a C# script class named MyGUIButton ...