This repository contains a Pong game which goes through a number of steps as it is gradually decomposed into smaller bits and pieces. The intention here is to demonstrate the techniques - for the example Pong game it makes little difference, but the same principles can be used successfully on larger projects.
It is the companion source code to my Unite Berlin 2018 presentation, "From Pong to 15-person project".
See the presentation (45 mins) at the start of this video.
Slides as PDF within the repository.
This is a straight-forward implementation of the Pong game. One MonoBehaviour for each 'thing' in the game.
Any parameters in prefabs which are not intended to be tweaked individually per-instance has been moved to ScriptableObjects. This makes it easier to see in the editor which prefab values are intended to be tweaked per-instance and which shouldn't (these parameters need to be edited via the shared ScriptableObjects instead).
The bulk of logic has been moved out of MonoBehaviours and into separate Logic/Simulation/etc classes. MonoBehaviours are mostly controlling object lifetime and ensuring Unity engine callbacks are forwarded to the appropriate classes.
Delegates and interfaces are used to make Logic/Simulation/etc classes be more self-contained, with the adaptation logic present in the MonoBehaviour.
A coroutine which does several fiddly things has been broken into sub-coroutines. This creates a bit more separation between intent and execution.