当前位置:网站首页>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.
边栏推荐
- Can't load /home/Iot/.rnd into RNG
- 【SemiDrive源码分析】【MailBox核间通信】44 - 基于Mailbox IPCC RPC 实现核间通信(RTOS侧 IPCC_RPC Server 消息接收及回复 原理分析篇)
- MySQL 8.0.30 GA
- volatile内存语义以及实现 -volatile写和读对普通变量的影响
- Understanding of the presence of a large number of close_wait states
- 微信小程序使用云函数更新和添加云数据库嵌套数组元素
- No qualifying bean of type question
- MySQL基础操作
- [C language] General method of base conversion
- 简易网络文件拷贝的C实现
猜你喜欢
C语言表白代码?
Unity Fighter
开源汇智创未来 | 2022开放原子全球开源峰会OpenAtom openEuler分论坛圆满召开
打造基于ILRuntime热更新的组件化开发
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
【R语言】【3】apply,tapply,lapply,sapply,mapply与par函数相关参数
C language from entry to such as soil, the data store
Win10 CUDA CUDNN 安装配置(torch paddlepaddle)
pom文件成橘红色未加载的解决方案
How Zotero removes auto-generated tags
随机推荐
Go语学习笔记 - 处理超时问题 - Context使用 | 从零开始Go语言
LocalDate addition and subtraction operations and comparison size
Understanding and Using Unity2D Custom Scriptable Tiles (4) - Start to build a custom tile based on the Tile class (below)
mysql基础知识(二)
Two address pools r2 are responsible for managing the address pool r1 is responsible for managing dhcp relays
Unity资源管理系列:Unity 框架如何做好资源管理
【py脚本】批量二值化处理图像
View source and switch mirrors in two ways: npm and nrm
VScode+ESP32快速安装ESP-IDF插件
Solved (the latest version of selenium framework element positioning error) NameError: name 'By' is not defined
prompt.ml/15中<svg>标签使用解释
产学研用 共建开源人才生态 | 2022开放原子全球开源峰会教育分论坛圆满召开
MySQL database must add, delete, search and modify operations (CRUD)
论治理与创新 | 2022开放原子全球开源峰会OpenAnolis分论坛圆满召开
three.js make 3D photo album
HCIP Day 10_BGP Route Summary Experiment
Understanding of the presence of a large number of close_wait states
[CV project debugging] CUDNN_CONVOLUTION_FWD_SPECIFY_WORKSPACE_LIMIT problem
Postgresql 15 source code analysis (5) - pg_control
MySQL based operations