Unity Game FrameWork—Framework Learning—Game Entry

E big Demo framework, the code is mainly divided into three parts.
Assets/UnityGameFramework/GameFramework: GF framework
Assets/UnityGameFramework/Scripts: UGF framework
Assets/GameMain/Scripts: Demo framework
insert image description here

Demo frame entry: GameEntry

Assets\GameMain\Scripts\Base\GameEntry.cs
initializes and obtains all components. The awake method of each component has been registered before obtaining. For the registration place, see the entry of the unity framework.

Unity framework entry: GameEntry

Assets\UnityGameFramework\Scripts\Runtime\Base\GameEntry.cs
related properties and methods:
s_GameFrameworkComponents:
GameFrameworkLinkedList
game framework linked list class, which stores all framework components, and joins the linked list when registering components.
GameFrameworkSceneId:
The number of the scene where the game frame is located, the setting value is 0. The scene component will use this property to get the scene where the frame is located.
T GetComponent() :
Get the game framework component.
Shutdown(ShutdownType):
Close the game frame, switch language, version detection, resource update, it will be called when exiting the game.
The enumeration of the incoming type when closing the frame is as follows
public enum ShutdownType: byte
{ None = 0,//only close the game frame Restart,//close the game frame and restart the game Quit,//close the game frame and exit the game } generally not used Only close the game framework. This function is only available in the Debug directory. All components that come with the framework will be cleared. Custom components will not be cleared, and the game entry of the framework will still be retained. When restarting, the scene where the game framework is located will be loaded according to the GameFrameworkSceneId. RegisterComponent(GameFrameworkComponent):






Register frame components, all frame components have entities in the frame prefab. When the game starts, the Aweak method in the component will first call this function to add the component itself to the game framework linked list class to complete the component registration. After the registration is complete, the Start of the Demo framework entry GameEntry will obtain all components, which is convenient for subsequent calls to the functions of the framework components.

Native framework entry: GameFrameworkEntry

Assets\UnityGameFramework\GameFramework\Base\GameFrameworkEntry.cs
related properties and methods:
s_GameFrameworkModules:
GameFrameworkLinkedList
game framework module linked list.
Update:
Game framework module polling.
This method is called by BaseComponent, the base component of the unity framework, in the update method to complete the call module for each frame.
Shutdown:
Close and clean up all game module frameworks, BaseComponent is called in the OnDestroy method.
GetModule:
Get the framework module, if there is no one, it will be created.
The instance method of creating a class is as follows:
GameFrameworkModule module = (GameFrameworkModule)Activator.CreateInstance(moduleType);

Summarize

Among the three framework entrances, we can easily find the connection between the Demo framework entrance and the unity framework entrance, and the relationship is very clear. However, the connection between the entry of the native framework and the entry of the unity framework is very vague. Only BaseComponent, the basic component of the unity framework, has established a connection with the entry of the native framework to complete polling and delete the framework module.
By looking up the reference of the GetModule method, we can find that the components of the unity framework will obtain the modules of the native framework, which is generally a one-to-one correspondence.
insert image description here
What is the corresponding relationship and what is the basis for obtaining the module? Let's continue to learn.

Supongo que te gusta

Origin blog.csdn.net/qq_37619255/article/details/129090894
Recomendado
Clasificación