Unity Game FrameWork—module usage—GameEntry package

At the beginning of the framework, unity has made a thin layer of encapsulation based on the Game FrameWork framework to simplify the writing method when calling.
After encapsulation:
GameEntry.UI.OpenUIForm(“”, “”, this);
Before encapsulation:
UnityGameFramework.Runtime.GameEntry.GetComponent().OpenUIForm(“”, “”, this);
Encapsulation principle:
in In StarForce, GameEntry is divided into two parts:
GameEntry that comes with the framework
insert image description here

The two partial types GameEntry included in the case (GameEntry.Builtin, GameEntry.Custom)
insert image description here


Partial type (partial): Allows us to divide a class, structure or interface into several parts, and implements the components in the framework in GameEntry.Builtin in several different .cs files , and initializes the components when the game starts.
Custom components can be added to GameEntry.Custom and initialized when the game starts.
The GameEntry code is as follows, call GameEntry.Builtin and GameEntry.Custom to initialize the component. This script is mounted on the Game Framework prefab.

using UnityEngine;
using UnityGameFramework.Runtime;
namespace StarForce
{
    
    
    /// <summary>
    /// 游戏入口。
    /// </summary>
    public partial class GameEntry : MonoBehaviour
    {
    
    
        private void Start()
        {
    
    
            InitBuiltinComponents();
            InitCustomComponents();
        }
    }
}

insert image description here

Guess you like

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