The best architecture to create Unity project based on Canvas and is flexible enough to be implemented even on top of ECS or OOP.
This is a sample project I have made to demonstrate the AMVC architecture. It consists of two scene:
- Loading Scene : when we send few requests to fill our models with the necessary data. The loading system based on Command Design Pattern to make it flexible when we need to reload or skip some thing or even to handle errors more efficiently. the DataBaseManager is a helper class built to integrate the Rest Client for Unity plugin into the AMVC architecture.
- Main Scene : I consume the Api result with two different ways to explain how the Controller (Systems) and Views (Panels) communicate.
Also you will notice that all my UI Panels are canvases. and the reason to use multiple canvases is to avoid regenerating the meshes when UI elements change. Read More about it
The Application Model View Controller (AMVC) solve any dependencies issues by spliting the software into :
- Single entry point "Application" : contain and manage all critical instances and application-related data.
- Three major components:
- Models : Data CRUD.
- Views : UI Panels.
- Controllers : Application systems.
all panels and systems are accessible from anywhere using GetPanel<T> and GetSystem<T> respectively.