[预读]
Unreal Reflection System: https://docs.unrealengine.com/latest/INT/Programming/Introduction/index.html
下面这段话来自上述链接:
The base building block in the Unreal Engine is called UObject. This class, coupled with UClass, provides a number of the most important base services in the engine:
-
Reflection of properties and methods
-
Serialization of properties
-
Garbage collection
-
Create UObjects && Finding UObjects by name
-
Configurable values for properties
-
Networking support for properties and methods
Each class that derives from UObject has a singleton UClass created for it that contains all of the meta data about the class instance. UObject and UClass together are at the root of everything that a gameplay object does during its lifetime. The best way to think of the difference between a UClass and a UObject is that the UClass describes what an instance of a UObject will look like, what properties are available for serialization, networking, etc.
整个对象系统,跟UE3比较起来变化不大。目前针对UE4 11版本来看,Blueprint对应以前的uc脚本系统。 UE3通过在uc中定义一些uc class属性,通过uc编译器进行生成C++头文件;UE4通过在C++的头文件中的类定义中加入些宏(确切地说是空宏),让UnrealHeaderTool对.h文件进行预处理,产生一些C++ .h,.cpp文件,这些代码充当胶水层,将C++ Class加入Reflection功能。对象依然采用命名空间方法命名(应该是学习Java的包命名方式的)。
基石模块:
RunTime\UObjectCore 对象系统
RunTime\Core 封装平台相关代码和算法
我们先从C++类反射开始, 然后再考虑blueprint, 因为原理是一样的(其实你也可以换成别的脚本系统)。将从如下几个方面进行着手游历这个对象系统:
1. 对象的类描述,主要通过UClass类来实现。
a. 与UClass的相关概念
b. UClass实例的创建
c. 分析一个由UnrealHeaderTool生成的反射代码
2. 对象的创建流程和管理
3. 对象的序列化, 文件格式,Linker
4. 垃圾回收流程和机制
5. Blueprint的原理 和 VM
a. Blueprint的可视化描述
b. 字节码生成
c. VM的执行
6. 模块机制,如何实现hot-reload
7. 对象的Replication(Network)
上述内容不一定是完全细致到位的,每篇后面可能会留一些悬疑问题,需要根据后面的体会和理解 持续更新和修正。