public WorldStaticVar(GetDefaultValueHandler getDefaultValue, params EWorldType[] worldTypes) { GetDefaultValue = getDefaultValue; foreach (EWorldType worldType in worldTypes) { worldTypeFlags |= (1 << (int)worldType); } // Initialize the value for already created worlds FWorldContext[] worldContexts = FWorldContext.GetWorldContexts(); foreach (FWorldContext worldContext in worldContexts) { if (worldContext.CurrentWorld != IntPtr.Zero) { int worldType = (1 << (int)worldContext.WorldType); if ((worldTypeFlags & worldType) == worldType) { UObject world = GCHelper.Find(worldContext.CurrentWorld); if (world != null) { Set(world, GetDefaultValue(world)); } } } } }
private IntPtr GetDefaultWorld() { #if WITH_EDITORONLY_DATA FWorldContext worldContext = new FWorldContext(Native_UEditorEngine.GetPIEWorldContext(FGlobals.GEditor)); return(worldContext.IsNull ? IntPtr.Zero : worldContext.CurrentWorld); #else return(Native_UObject.GetWorld(FGlobals.GEngine)); #endif }