MVC in Code Control


If you are new to the MVC design pattern you’re in the right spot, because Code Control is designed to be the easiest to understand MVC framework for Unity!

MVC is one of the many design patterns out there, which are solutions to commonly occurring problems in software design. MVC separates an object into three units: a Model, a View and a Controller. Separating responsibility improves readability and re-usability of code and makes refactoring easier. The following table explains the three responsibilities in more detail.


The model represents the data of an object. In addition to the data itself, a model usually contains some functionality to save/load its data.

In Code Control, the Model is implemented as an abstract class that can be extended into a custom Model.


The View is responsible for displaying the object based on the Model’s data. It contains only the needed logic to respond to user input, and sends relevant interaction towards the controller.

To keep things as simple and adaptable as possible, no abstraction of the View is implemented in Code Control. This is all for you to implement!


The Controller contains logic that responses to its View and changes the data of its Model accordingly.

In Code Control, the Controller is implemented as a derived class of Unity’s MonoBehaviour, and it has a life-link to a Model.

Why use Code Control?

Why use Code Control for MVC in Unity? Well, Code Control’s Model class contains extended functionality to save and load your Models easily. The Controller automatically gets a life-link with its Model, destroying itself when the Model no longer exists. Controllers can easily communicate with each other while staying decoupled using Code Control’s build in Message System, and all of this can be monitored using Code Control’s insightful Unity Editor extensions. Last but not least, Code Control takes care of a tricky┬áreferencing problem that arises in basic serialization.

Next step

Curious about how to get started using Code Control? Then take a look at the tutorials section!