• UE引擎的UWorld是什么,UWorld与GWorld的关系


    UE引擎的UWorld是什么,UWorld与GWorld的关系

    UWorld有一些关于游戏的重要信息,比如(PersistentLevelNetDriverGameState),没有它,你不能做你想做的大部分事情。

    GWorld是个全局指针变量,指向UWorld的指针(Global UWorld pointer)。

    定义在文件:Engine\Source\Runtime\Engine\Classes\Engine\World.h

    1. /** Global UWorld pointer. Use of this pointer should be avoided whenever possible. */
    2. extern ENGINE_API class UWorldProxy GWorld;

       World 是代表地图或沙箱的顶级对象,Actor 和组件将存在于其中并进行渲染。
      一个世界可以是一个单一的持久关卡,带有一个可选的流式关卡列表,这些关卡通过卷和蓝图函数加载和卸载或者它可以是使用 World Composition 组织的关卡集合。
      在独立游戏中,通常只有一个世界存在,除非在无缝区域转换期间同时存在目的地和当前世界。
      在编辑器中存在许多世界:正在编辑的关卡、每个 PIE 实例、每个具有交互式渲染视口的编辑器工具等等。

    1. class UWorld : public UObject
    2. {
    3. public:
    4. // ...
    5. class ULevel* PersistentLevel;
    6. class UNetDriver* NetDriver;
    7. class AGameNetworkManager* NetworkManager;
    8. // ...
    9. class AGameStateBase* GameState;
    10. // ...
    11. class ULevel* CurrentLevel;
    12. class UGameInstance* OwningGameInstance;
    13. // ...
    14. };

    UWorld代理类:

    1. /** Proxy class that allows verification on GWorld accesses. */
    2. class UWorldProxy
    3. {
    4. public:
    5. UWorldProxy() :
    6. World(NULL)
    7. {}
    8. inline UWorld* operator->()
    9. {
    10. // GWorld is changed often on the game thread when in PIE, accessing on any other thread is going to be a race condition
    11. // In general, the rendering thread should not dereference UObjects, unless there is a mechanism in place to make it safe
    12. checkSlow(IsInGameThread());
    13. return World;
    14. }
    15. inline const UWorld* operator->() const
    16. {
    17. checkSlow(IsInGameThread());
    18. return World;
    19. }

    在内存中查看UWorld:

    FirstPersonExampleMap    0x216542AEAC0    World 

     查看 UWorld偏移量:ExeModuleBase+0x5B14EB8

    查看UWorld内存布局:

     

  • 相关阅读:
    数据传输如何做才安全:保障隐私的5大秘诀!
    小程序:如何合理规划分包使主包不超过2M
    js的slice()和splice()
    LeetCode 15. 三数之和(C++)
    基于51单片机的出租车计价器proteus仿真原理图PCB
    【MySQL】根据查询结果更新统计值
    企业内网远程桌面控制软件及解决方案
    Spring中Bean的实例化详细流程
    理论与实践:如何写好一个方法
    kubernetes popeye 巡检
  • 原文地址:https://blog.csdn.net/a2831942318/article/details/127932456