当前位置:网站首页>Create componentized development based on ILRuntime hot update
Create componentized development based on ILRuntime hot update
2022-07-31 04:44:00 【Clank's Game Stack】
Build component development based on ILRuntime
In the previous section, we explained in detail the startup process of the ILRuntime game project framework, as well as the entry into the hot update project, which laid a solid foundation for us to build the framework. The logical hot update project is completed with C#.Therefore, in the logic hot update project, we ensure that the development is not much different from the ordinary Unity C#, so today we will design a componentized development mechanism based on the logic hot update project, we call it ILRBehaviour, similar to MonoBehaviour, try our best toEnsure that all development habits are very similar to MonoBehaviour. Since MonoBehaviour is a data object type in the Unity C# domain, we cannot use it directly in the logic hotfix project, so we have to design a set of class-based mechanisms by ourselves, mainly to accomplish 3 things:
There is a Game Development Communication Team
a> Everyone can go to get the source material to learn and communicate together
Design ILRBehaviour interface
The design of the ILRBehaviour interface is mainly consistent with MonoBehaviour. The common development habits of MonoBehaviour are mainly interface + gameObject + transform object. Later, we will do a good job in the collision detection interface of the physics engine.Regarding the timer of MonoBehaviour, we will design a timer module separately to do the timer, instead of simulating the timer mechanism of MonoBehaviour.With this consideration, the data members and interfaces of our ILRBehaviour can be designed,
As follows:
class ILRBehaviour {public GameObject gameObject; // Simulation component instance.gameObject;public Transform transform; // Simulate component instance.transform;virtual public void Awake() {}virtual public void Start() {}virtual public void Update() {}virtual public void LateUpdate() {}virtual public void FixedUpdate() {}virtual public void onDestroy() {}}What's different from MonoBehaviour here is that the interface of the base class is made a virtual function directly, instead of looking up through reflection to see if the subclass has this method like MonoBehaviour.Therefore, when the subclass overloads the interface function, the override keyword is added.
Add, find, delete ILRBehaviour component instance mechanism
In Unity's development habits, the GameObject class is used to add components. Here GameObject is a natvie c# object, so other methods must be found. Here I added a global singleton of ILRBeahviourMgr to add an instance of the ILRehaviour component.Find, delete.
ILRBehaviour AddILRComponent(GameObject gameObject, Type classType)
public T AddILRComponent
How does this principle work?All MonoBehaviour components in Unity C# GameObject are "hanging" on the GameObject node instance, but for the logic hot change project, GameObject is a nativie C# object, which cannot be directly recorded on it. Our design here is to build here ILRBehaviourMgrA dictionary Dictionary

Figure 1.4-1: AddILRComponent Process Details
Other search and delete interfaces are similar. I won't analyze them one by one here. You can check the source code.
Let the specific interface of ILRBehaviour be called at a specific time
After designing the interface of adding, searching, and deleting the ILRBehaviour component, the next step is to make the specific interface in the ILRBehaviour component mechanism be called at a specific period.The specific period of the current hot update comes from Unity C#, and the entry is in main.cs, so if we want to make the specific interface in the ILRBehaviour component callable, we can start from the specific interface in main.cs, letThey call the specific interface in ILRBehaviourMgr, and then in IlRBehaviourMgr, we traverse each gameObject in the behaviorMap, find the List array list of ILRBehaviour that belongs to it, traverse each ILRBehaviour component instance in it, and call the specific interface.Let's take update as an example to analyze:

The whole process is shown in Figure 1.4-2.

Figure 1.4-2: The whole process of triggering ILRBehaviour.Update call
After implementing these mechanisms, we have designed a complete set of componentized development mechanism based on ILRBehaviour, which combines the previous Mono development habits of Unity c# as much as possible, so that other small partners can seamlesslyDo development in the hot update project.Finally, the last architecture diagram, deepen the impression.

Figure 1.4-3: ILRBehaviour. Mechanism Design Architecture
That's it for today's sharing, you can go to the study group announcement, you can get the source code of our ILRuntime hot update tutorial, and it's more sour to look at the source code.
边栏推荐
- MySQL修改root账号密码
- LocalDate addition and subtraction operations and comparison size
- Musk talks to the "virtual version" of Musk, how far is the brain-computer interaction technology from us
- 开放原子开源基金会秘书长孙文龙 | 凝心聚力,共拓开源
- prompt.ml/15中<svg>标签使用解释
- [AUTOSAR-RTE]-5-Explicit (explicit) and Implicit (implicit) Sender-Receiver communication
- (5) final, abstract class, interface, inner class
- 专访 | 阿里巴巴首席技术官程立:云+开源共同形成数字世界的可信基础
- 【AUTOSAR-RTE】-4-Port and Interface and Data Type
- 扫雷游戏(c语言写)
猜你喜欢

Two address pools r2 are responsible for managing the address pool r1 is responsible for managing dhcp relays

MATLAB/Simulink & & STM32CubeMX tool chain completes model-based design development (MBD) (three)

Musk talks to the "virtual version" of Musk, how far is the brain-computer interaction technology from us

【wpf】wpf中的那些模板之深度解析

Knowledge Distillation 7: Detailed Explanation of Knowledge Distillation Code

Unity资源管理系列:Unity 框架如何做好资源管理

MySQL数据库必会的增删查改操作(CRUD)

LocalDate addition and subtraction operations and comparison size

SOLVED: After accidentally uninstalling pip (two ways to manually install pip)

MySQL数据库增删改查(基础操作命令详解)
随机推荐
Minesweeper game - C language
C# 实现PLC的定时器
三道leetcode上的oj题
Fusion Cloud Native, Empowering New Milestones | 2022 Open Atom Global Open Source Summit Cloud Native Sub-Forum Successfully Held
HCIP第十天_BGP路由汇总实验
View source and switch mirrors in two ways: npm and nrm
Safety 20220718
【debug锦集】Expected input batch_size (1) to match target batch_size (0)
微软 AI 量化投资平台 Qlib 体验
【wpf】wpf中的那些模板之深度解析
VScode+ESP32 quickly install ESP-IDF plugin
$attrs/$listeners
(4) Recursion, variable parameters, access modifiers, understanding main method, code block
(八)Math 类、Arrays 类、System类、Biglnteger 和 BigDecimal 类、日期类
Can't load /home/Iot/.rnd into RNG
已解决:不小心卸载pip后(手动安装pip的两种方式)
益智类游戏关卡设计:逆推法--巧解益智类游戏关卡设计
Open Source Smart Future | 2022 OpenAtom Global Open Source Summit OpenAtom openEuler sub-forum was successfully held
重磅 | 开放原子校源行活动正式启动
[Paper reading] Mastering the game of Go with deep neural networks and tree search