当前位置:网站首页>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.
边栏推荐
- 专访 | 阿里巴巴首席技术官程立:云+开源共同形成数字世界的可信基础
- PWN ROP
- Industry-university-research application to build an open source talent ecosystem | 2022 Open Atom Global Open Source Summit Education Sub-Forum was successfully held
- (Line segment tree) Summary of common problems of basic line segment tree
- idea工程明明有依赖但是文件就是显示没有,Cannot resolve symbol ‘XXX‘
- unity2d小游戏
- (六)枚举、注解
- Vue项目通过node连接MySQL数据库并实现增删改查操作
- ENSP,划分VLAN、静态路由,三层交换机综合配置
- Safety 20220715
猜你喜欢

The input input box displays the precision of two decimal places

WeChat applet uses cloud functions to update and add cloud database nested array elements

重磅 | 基金会为白金、黄金、白银捐赠人授牌

已解决(最新版selenium框架元素定位报错)NameError: name ‘By‘ is not defined

Basic knowledge of mysql (2)

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

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

Open Source Database Innovation in the Digital Economy Era | 2022 Open Atom Global Open Source Summit Database Sub-Forum Successfully Held

强化学习:从入门到入坑再到拉屎

已解决:不小心卸载pip后(手动安装pip的两种方式)
随机推荐
MySQL to revise the root password
MySQL database must add, delete, search and modify operations (CRUD)
ENSP, VLAN division, static routing, comprehensive configuration of Layer 3 switches
XSS靶场(三)prompt to win
产学研用 共建开源人才生态 | 2022开放原子全球开源峰会教育分论坛圆满召开
开源社区三十年 | 2022开放原子全球开源峰会开源社区三十年专题活动圆满召开
Knowledge Distillation 7: Detailed Explanation of Knowledge Distillation Code
MATLAB/Simulink&&STM32CubeMX工具链完成基于模型的设计开发(MBD)(三)
[CV project debugging] CUDNN_CONVOLUTION_FWD_SPECIFY_WORKSPACE_LIMIT problem
ERROR 1064 (42000) You have an error in your SQL syntax; check the manual that corresponds to your
Gaussian distribution and its maximum likelihood estimation
【C语言进阶】文件操作(一)
高斯分布及其极大似然估计
Understanding of the presence of a large number of close_wait states
(tree) Last Common Ancestor (LCA)
MySQL修改root账号密码
(Line segment tree) Summary of common problems of basic line segment tree
Safety 20220715
开放原子开源基金会秘书长孙文龙 | 凝心聚力,共拓开源
Why don't you programmers make a living off your own projects?And have to work for someone else?