“This is the 25th day of my participation in the Gwen Challenge in November. See details: The Last Gwen Challenge in 2021”

👉 About the author

As we all know, life is a long process of constantly overcoming difficulties and reflecting on progress. In this process, there will be a lot of questions and thoughts about life, so I decided to share my thoughts, experiences and stories to find resonance!!

Focus on Android/Unity and various game development tips, as well as various resource sharing (websites, tools, materials, source code, games, etc.)

Welcome to pay attention to the public account [Mr. Empty name] for more resources and communication!

👉 premise

Looking at official documents or case studies is a quick way to learn.

We just studied the Game Framework Framework, how can we do it without a case; Although there is an official finished case, the author is often “doggy”, there is no official tutorial.

But that’s okay. Let’s take a look

👉 Practice

😜 Download items

Create a local folder and use Git to download the project (recommended)

  • 1.git init
  • 2. The git clone github.com/EllanJiang/…
  • 3. If downloading from Github is slow, you can download it from Gitee

Git clone gitee.com/jiangyin/St…

Use Unity to open the project, mine is Unity2019.4.9 F1 version, opening may be a little slow, no hurry, wait.

Go inside and run the StarForce Launcher to start the game. (There may be some error in the API or something in the script when different Unity versions are opened. Please modify it accordingly.)

😜 Looking for an entrance

Any game entrance is the first impression, the program entrance is the development of the entrance. It is also quick to find the entrance of the case. There is a scene of StarForce Launcher. Click on it and find an object with only a Game Framework and a [GameEntry] script attached.

There are only two function methods; That simple? Click inside to see;

private static void InitBuiltinComponents()
{
    Base = UnityGameFramework.Runtime.GameEntry.GetComponent<BaseComponent>();
    Config = UnityGameFramework.Runtime.GameEntry.GetComponent<ConfigComponent>();
    DataNode = UnityGameFramework.Runtime.GameEntry.GetComponent<DataNodeComponent>();
    DataTable = UnityGameFramework.Runtime.GameEntry.GetComponent<DataTableComponent>();
    Debugger = UnityGameFramework.Runtime.GameEntry.GetComponent<DebuggerComponent>();
    Download = UnityGameFramework.Runtime.GameEntry.GetComponent<DownloadComponent>();
    Entity = UnityGameFramework.Runtime.GameEntry.GetComponent<EntityComponent>();
    Event = UnityGameFramework.Runtime.GameEntry.GetComponent<EventComponent>();
    FileSystem = UnityGameFramework.Runtime.GameEntry.GetComponent<FileSystemComponent>();
    Fsm = UnityGameFramework.Runtime.GameEntry.GetComponent<FsmComponent>();
    Localization =  UnityGameFramework.Runtime.GameEntry.GetComponent<LocalizationComponent>();
    Network = UnityGameFramework.Runtime.GameEntry.GetComponent<NetworkComponent>();
    ObjectPool = UnityGameFramework.Runtime.GameEntry.GetComponent<ObjectPoolComponent>();
    Procedure = UnityGameFramework.Runtime.GameEntry.GetComponent<ProcedureComponent>();
    Resource = UnityGameFramework.Runtime.GameEntry.GetComponent<ResourceComponent>();
    Scene = UnityGameFramework.Runtime.GameEntry.GetComponent<SceneComponent>();
    Setting = UnityGameFramework.Runtime.GameEntry.GetComponent<SettingComponent>();
    Sound = UnityGameFramework.Runtime.GameEntry.GetComponent<SoundComponent>();
    UI = UnityGameFramework.Runtime.GameEntry.GetComponent<UIComponent>();
    WebRequest = UnityGameFramework.Runtime.GameEntry.GetComponent<WebRequestComponent>();
}
Copy the code

InitBuiltinComponents()- Initializes built-in components by name.

Wait, there’s something wrong! How does it feel like a different file?

GameEntry actually has three classes, I miles go, pretty 6 ah. Partial class is the partial class.

Partial class is a partial class keyword. What is partial class? It is to divide the code of a class according to different content logic, and then write in different files, which is conducive to multiple developers to deal with the class at the same time, both enhance readability and practical. In addition, it is better to normalize the name, such as the main class file name AClass, and the sub-class name aclass.partname.

There are a few other things to note about the Partial keyword

  • 1. Use partial for all partial classes
  • 2. The access permissions of each part should be consistent. If it is public, it is public, and if it is other, it is other
  • 3. If one of them declares an abstract type, the whole type is abstract
  • 4. Any classes, structures, etc. within them can be used with each other

👉 other

📢 author: Kom and Kom in Kom

📢 reprint instructions – be sure to specify the source: Zhim Granular’s personal home page – column – Nuggets (juejin. Cn)

📢 welcome to like 👍 collect 🌟 message 📝