WorldContext

答案是否定的,首先World就不是只有一種類型,比如編輯器本身就也是一個(gè)World,里面顯示的游戲場(chǎng)景也是一個(gè)World,這兩個(gè)World互相協(xié)作構(gòu)成了我們的編輯體驗(yàn)。然后點(diǎn)播放的時(shí)候,引擎又可以生成新的類型World來(lái)讓我們測(cè)試。簡(jiǎn)單來(lái)說(shuō),UE其實(shí)是一個(gè)平行宇宙世界觀。
以下是一些世界類型:

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 Inactive // An editor world that was loaded but not currently being edited in the level editor };
}

而UE用來(lái)管理和跟蹤這些World的工具就是WorldContext:

FWorldContext保存著ThisCurrentWorld來(lái)指向當(dāng)前的World。而當(dāng)需要從一個(gè)World切換到另一個(gè)World的時(shí)候(比如說(shuō)當(dāng)點(diǎn)擊播放時(shí),就是從Preview切換到PIE),F(xiàn)WorldContext就用來(lái)保存切換過(guò)程信息和目標(biāo)World上下文信息。所以一般在切換的時(shí)候,比如OpenLevel,也都會(huì)需要傳FWorldContext的參數(shù)。一般就來(lái)說(shuō),對(duì)于獨(dú)立運(yùn)行的游戲,WorldCo