After almost two days working on the menu, it’s finally working and contains audio and video options.
It contains MenuBoards
like main menu, settings, quit game confirmation, etc. Each of those contain UIElements
, which can be a button, label, checkbox, combobox or slider. Those are layouted around the screen center.
All those elements are text based, so on display they grab a free letter from the LetterPool
and retrieve either a freshly created one or a letter that has been abandoned by another UIElement
that got hidden.
The Letter
is just a container for the state (highlighted, fade, position, velocity) and has the logic to transition towards its current goal.
The letters animate their position either towards their position in an UIElement
or towards a random position (with a slight tendency to fall down) when they have been abandoned.
The position, highlight flag, velocity and letter are grabbed by the LetterPool
and filled into arrays of a MaterialPropertyBlock
and then the whole thing is rendered using a Graphics.DrawMeshInstanced
call.
Each letter is a Quad
with a special shader that has the whole font as a texture and manages the fading, glitching, stretching (to keep the aspect of letters with different widths correct) and has instanced properties for the ones coming in through the MaterialPropertyBlock
.