A friend presented an interesting challenge about making a car upgrade system that had to comprise of the following:
- Change the colour of the car
- Select different car models
- Output specification and prices relevant to parts used
- Graphics don't matter.
With these details in mind I tried to think of the most effective way to complete this. I measured success in hitting all the points in as little script as possible.
Outcome
Completing the project in total took around 3 hours of dev time. I relied heavily on the Unity "on click" methods in the UI to switch between UIs and cameras whilst also running methods in scripts to reduce as much coding as possible. I also setup my scripts in a way that meant I could essentially create parallel arrays for gameobjects, costs and descriptions then use this script in multiple instances for the various parts of the car. These scripts would then feedback information to a GameManager script which handled the information and displayed it to the UI. The final script was simply an inheritance script for the first script that allowed for the car body to change colour. This could've went into the parent script but it felt more suitable to show the use of inheritance in a place that was suitable for it.