Unity Game FrameWork—Framework Learning—Component to Module Encapsulation

Let's take the entity component as an example. After calling base.Awake() in the entity component to complete the registration of the component, the module will be obtained immediately. The module obtained by the entity component is the interface of the entity manager.
insert image description here
There are many entity-related events and processing methods for related entity groups, numbers, and additions in the interface of the entity manager.
insert image description here
Let's look down at where the interface of the entity manager is implemented. Through breakpoint debugging, we can see that the module name at this time has changed to EntityManager. This place is very critical. The IEntityManager entity manager interface is converted to the EntityManager entity manager through string interception.
insert image description here
Activator.CreateInstance(moduleType) creates the entity manager class EntityManager through the class name, and then calls the construction method of the entity manager.
insert image description here
insert image description here
At this point, actually obtaining modules is to obtain various manager classes ending with Manager. The functions implemented by each manager class are accomplished by inheriting the implementation interface.
The inheritance relationship framework module inheritance relationship is listed below
Native framework manager: framework module abstract class, manager interface
EntityManager: GameFrameworkModule, IEntityManager
GameFrameworkModule: game module abstract
class The abstract class has three fields or methods
Priority: module polling priority
Update( ): Polling method
Shutdown(): Close and clean up the framework module
Below, we collectively refer to the manager and the module as the manager
At this time, we can understand that the component creates the manager through the interface of the manager, and most of the methods of the component call the management Implemented by the method of the device.
insert image description here
The component creates a module and calls the function of the module. The realization of the function of the module depends on the manager. At this point, the package of the module by the component is completed.

Guess you like

Origin blog.csdn.net/qq_37619255/article/details/129091118