-
Notifications
You must be signed in to change notification settings - Fork 2
Widgets
New widgets can be created by extending the Widget class, or one of the base classes provided, like the scroll bar.
They do not have events by default, override the RegisterEvents class to subscribe to things like mouse clicks. Events will be registered in the widget registration order.
If you want a widget to position above other widgets, override the widget priority and set it to be higher (for things like dropdowns).
All widgets have a OnRender override. A base GUI shader is provided and set to be used. Methods for rendering GUI elements can be found in the static RenderTools class, such as RenderQuad or RenderNineSlice. The shader has uniforms such as color that can be set. A texture typically needs to be bound to the shader first, unless the render method takes one.
Text can be rendered by making a TextObject class with a font that can be retrieved from the FontRegistry by the ttf filename. Ttf fonts can be added to your assets in config/freetypefonts/. It can also be rendered directly to the font.
Subscribing an action to the widget's OnResize event to set the TextObject's size to fit inside the widget with the SetScaleBasedOnSize method can be done.