Mar5

Delegates and UI Programming

or: a perfect match.

I am using Delegates to define UI content in functions. Switching UI windows is as easy as changing the delegate assignments. My previous system used a MonoBehavior-Derived component for each UI Window, which gave me around 30 components to handle. Now I have one component and one static class, that holds all the window content code. Drawing is handled by a single GameObject with the main UI component attached.

This approach uses less GameObject and Component and therefore is faster than a GameObject-based handling of different UI windows.