Are you ready to start using the SOLID principals in your Unity3D Project? Learn how the Open Closed Principal (the O in SOLID) can make your game easier to develop, extend, and maintain. By using simple interfaces and separating out some code, we’ll convert a solution that’s destined for messiness into a clean and SOLID Unity3D project.
What to Look Out For
- Adding new functionality requires you to modify your existing classes
- Your class is handling different inputs in different ways to the same method.
- You start to see if & else if statements cluttering your code.
Ways to Implement The Open Closed Principal in Unity
- Have your classes act on interfaces, not discrete implementations
- Use base classes and override their functionality
- Add events to your class and have other components on the gameobject register for those events instead of the class calling them directly