当前位置:网站首页>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 togetherDesign 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.
边栏推荐
- "DeepJIT: An End-To-End Deep Learning Framework for Just-In-Time Defect Prediction" paper notes
- exsl文件预览,word文件预览网页方法
- 微软 AI 量化投资平台 Qlib 体验
- Industry-university-research application to build an open source talent ecosystem | 2022 Open Atom Global Open Source Summit Education Sub-Forum was successfully held
- 【小土堆补充】Pytorch学习笔记_Anaconda虚拟环境使用
- Industry landing presents new progress | 2022 OpenAtom Global Open Source Summit OpenAtom OpenHarmony sub-forum was successfully held
- (Line segment tree) Summary of common problems of basic line segment tree
- MySQL based operations
- C# 实现PLC的定时器
- Minesweeper game - C language
猜你喜欢
Recursive implementation of the Tower of Hanoi problem
ENSP,划分VLAN、静态路由,三层交换机综合配置
【小土堆补充】Pytorch学习笔记_Anaconda虚拟环境使用
Go语学习笔记 - 处理超时问题 - Context使用 | 从零开始Go语言
Open Source Smart Future | 2022 OpenAtom Global Open Source Summit OpenAtom openEuler sub-forum was successfully held
ERROR 2003 (HY000) Can‘t connect to MySQL server on ‘localhost3306‘ (10061)
【C语言进阶】文件操作(一)
开源汇智创未来 | 2022开放原子全球开源峰会OpenAtom openEuler分论坛圆满召开
Hand in hand to realize the picture preview plug-in (3)
Unity资源管理系列:Unity 框架如何做好资源管理
随机推荐
开源社区三十年 | 2022开放原子全球开源峰会开源社区三十年专题活动圆满召开
IDEA common shortcut keys and plug-ins
$parent/$children and ref
(6) Enumeration and annotation
【wpf】wpf中的那些模板之深度解析
The third is the code to achieve
扫雷小游戏——C语言
Error EPERM operation not permitted, mkdir ‘Dsoftwarenodejsnode_cache_cacach两种解决办法
Notes on the establishment of the company's official website (6): The public security record of the domain name is carried out and the record number is displayed at the bottom of the web page
HCIP第十天_BGP路由汇总实验
BUG消灭者!!实用调试技巧超全整理
Can't load /home/Iot/.rnd into RNG
npm、nrm两种方式查看源和切换镜像
open failed: EACCES (Permission denied)
微信小程序使用云函数更新和添加云数据库嵌套数组元素
VScode+ESP32快速安装ESP-IDF插件
exsl文件预览,word文件预览网页方法
[shell basics] determine whether the directory is empty
idea工程明明有依赖但是文件就是显示没有,Cannot resolve symbol ‘XXX‘
binom二项分布,