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)); } } } } }
public GameStaticVar(GetDefaultValueHandler getDefaultValue) { GetDefaultValue = getDefaultValue; if (GetDefaultValue != null) { #if WITH_EDITOR IntPtr pieWorldContext = Native_UEditorEngine.GetPIEWorldContext(FGlobals.GEditor); if (pieWorldContext != IntPtr.Zero) { Value = GetDefaultValue(); } #else Value = GetDefaultValue(); #endif } }