Powerup track¶
An important inspiration for our concept is the powerup track from the classic Gradius series. It’s design allows the user to see their progression and choose what they want without having to move their fingers from the keyboard while in the middle of the action.
We hoped to implement this feature as well. In this document I will describe how we went about making it.
Plan behind the feature¶
In order to realize the system we had to look into possible functionalities in Unity that allows us to create something like this. For that reason we have been busy looking into the UI section of Unity.
For this feature we needed to get the following on screen:
- Squares as background elements
- Text
- Changing colors depending on which powerup is currently redeemable.
- All items next to one another
After research into possibilities, the parts above turned into the following possibilities:
- TMP Pro
- GUIBox
- Panels
- Text
- Image
- LayoutGroup
Of these, we opted to use TMP Pro, Images and LayoutGroups.
TMP Pro is a Unity component which leans itself well to displaying text on screen, which is what we wanted. This is better then the standard Unity Text, because this component is easier to implement.
Image is a bit of a misleading component name. While our project guidelines dictate that we cant use actual photos, the Image component can also be used to make easy shapes, like squares. The other options, GUIBox and Panels, were either more focussed on debugging or editor only.
LayoutGroups are the ideal way of bundeling items and keeping them neatly together. Using the different settings of this component we can easily get all items next to eachother and move them as a unit easier.
The code¶
In the sections below I will show the code of our current version of this feature. Do note that at the time of writing this document, the highlighting of the powerups based on the powerupvalue was not yet implemented.
Poweruptrack.cs¶
The Poweruptrack script consists out of 3 parts:
- The variables
- The Create() function
- The UpdateBlocks() function
Variables Poweruptrack¶
public class PowerupTrack : MonoBehaviour
{
private static HorizontalLayoutGroup _layoutgroup;
private static Powerup[] _availablePowerups;
private static float _powerupValue;
private static PowerupBlock[] _powerupBlocks;
. . .
}