这段时间在看UE的关卡切换的内容,发现要补的内容有很多,比如UE的整体结构。
本文主要参考了大钊的InsideUE4,记录一下自己的理解和想法。
本文从上往下梳理UE的结构。先放一张结构图。
Engine
首先是引擎级别,UE编辑器本身也是一个引擎。所以分为两个部分,这里我们主要研究UGameEngine
在Engine基类里保存会保存多个WorldContext。一般来说,UE只能同时存在一个World,但是可以相互切换。
UGameInstance
UGameInstance会保存当前的WorldContext和其他游戏的信息。不管Level如何切换,GameInstance中的信息都会一直存在。
WorldContext
一个World管理多个Level,并负责这些Level的加载和释放,下面是一些World类型
namespace EWorldType
{
enum Type
{
None, // An untyped world, in most cases this will be the vestigial worlds of streamed in sub-levels
Game, // The game world
Editor, // A world being edited in the editor
PIE, // A Play In Editor world
Preview, // A preview world for an editor tool
Inact