UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
LevelInstanceTypes.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "Misc/Guid.h"
9#include "LevelInstanceTypes.generated.h"
10
11// FLevelInstanceID is a runtime unique id that is computed from the Hash of LevelInstance Actor Guid and all its ancestor LevelInstance Actor Guids.
12// Resulting in a different ID for all instances whether they load the same level or not.
14{
17
18 inline friend uint32 GetTypeHash(const FLevelInstanceID& Key)
19 {
20 return ::GetTypeHash(Key.GetHash());
21 }
22
23 inline bool operator!=(const FLevelInstanceID& Other) const
24 {
25 return !(*this == Other);
26 }
27
28 inline bool operator==(const FLevelInstanceID& Other) const
29 {
30 return Hash == Other.Hash && ContainerID == Other.ContainerID && ActorName == Other.ActorName && PackageShortName == Other.PackageShortName;
31 }
32
33 inline bool IsValid() const { return !ContainerID.IsMainContainer(); }
34
35 inline uint64 GetHash() const { return Hash; }
36
37 inline const FActorContainerID& GetContainerID() const { return ContainerID; }
38
39private:
40 uint64 Hash = 0;
41 FActorContainerID ContainerID;
42
43 // Hashed only for Loaded LevelInstances
44 // Spawned LevelInstances have a unique Guid which is enough.
45
46 // Name allows distinguishing between LevelInstances with embedded parent LevelInstances because embedded actors have a guaranteed unique name (ContainerID suffix)
47 FName ActorName;
48 // PackageShortName allows distinguising between instanced LevelInstances of the same source level.
49 // - Loading /Game/Path/WorldA.WorldA as /Game/Path/WorldA_LevelInstance1.WorldA & /Game/Path/WorldA_LevelInstance".WorldA
50 // with the source WorldA containing one of many LevelInstance actors.
51 // Those actors would end up with the same hash. We use PackageShortName (WorldA_LevelInstance1 & WorldA_LevelInstance2) to distinguish them.
52 FString PackageShortName;
53};
54
55UENUM()
57{
59 // Deprecated exists only to avoid breaking Actor Desc serialization
61 // Move level instance actors to the main world partition
62 Partitioned UMETA(DisplayName = "Embedded"),
63 // Use level streaming to load level instance actors
64 LevelStreaming UMETA(DisplayName = "Standalone"),
65};
66
67UENUM()
73
74UENUM()
82
83USTRUCT()
85{
87
88 UPROPERTY(EditAnywhere, Category = Default, meta = (EditCondition = "!bHideCreationType", EditConditionHides, HideEditConditionToggle))
90
91 UPROPERTY(EditAnywhere, Category = Pivot)
93
94 UPROPERTY(EditAnywhere, Category = Pivot)
95 TObjectPtr<AActor> PivotActor = nullptr;
96
97 UPROPERTY()
98 bool bAlwaysShowDialog = true;
99
100 UPROPERTY()
101 TObjectPtr<UWorld> TemplateWorld = nullptr;
102
103 UPROPERTY()
104 FString LevelPackageName = TEXT("");
105
106 UPROPERTY()
107 bool bPromptForSave = false;
108
109 UPROPERTY()
110 TSubclassOf<AActor> LevelInstanceClass;
111
112 UPROPERTY()
113 bool bEnableStreaming = false;
114
115private:
116 UPROPERTY(EditAnywhere, Category = Default, meta = (EditCondition = "!bForceExternalActors", EditConditionHides, HideEditConditionToggle))
117 bool bExternalActors = true;
118
119 UPROPERTY()
120 bool bForceExternalActors = false;
121
122 UPROPERTY()
123 bool bHideCreationType = false;
124
125public:
126 void HideCreationType() { bHideCreationType = true; }
128 void SetExternalActors(bool bInExternalActors) { bExternalActors = bInExternalActors; }
129 bool UseExternalActors() const { return bForceExternalActors || bExternalActors; }
130};
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::uint64 uint64
A 64-bit unsigned integer.
Definition Platform.h:1117
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
return true
Definition ExternalRpcRegistry.cpp:601
ELevelInstanceCreationType
Definition LevelInstanceTypes.h:69
ELevelInstanceRuntimeBehavior
Definition LevelInstanceTypes.h:57
ELevelInstancePivotType
Definition LevelInstanceTypes.h:76
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define UENUM(...)
Definition ObjectMacros.h:749
#define USTRUCT(...)
Definition ObjectMacros.h:746
#define GENERATED_USTRUCT_BODY(...)
Definition ObjectMacros.h:767
uint8_t uint8
Definition binka_ue_file_header.h:8
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Actor.h:257
Definition NameTypes.h:617
Definition LevelInstanceInterface.h:33
Definition SubclassOf.h:30
Definition LevelInstanceSubsystem.h:55
Definition World.h:918
Definition AsyncRegisterLevelContext.cpp:16
@ false
Definition radaudio_common.h:23
Definition WorldPartitionActorContainerID.h:44
bool IsMainContainer() const
Definition WorldPartitionActorContainerID.h:96
Definition LevelInstanceTypes.h:14
uint64 GetHash() const
Definition LevelInstanceTypes.h:35
friend uint32 GetTypeHash(const FLevelInstanceID &Key)
Definition LevelInstanceTypes.h:18
const FActorContainerID & GetContainerID() const
Definition LevelInstanceTypes.h:37
FLevelInstanceID()
Definition LevelInstanceTypes.h:15
bool IsValid() const
Definition LevelInstanceTypes.h:33
bool operator!=(const FLevelInstanceID &Other) const
Definition LevelInstanceTypes.h:23
bool operator==(const FLevelInstanceID &Other) const
Definition LevelInstanceTypes.h:28
Definition LevelInstanceTypes.h:85
void SetForceExternalActors(bool bInForceExternalActors)
Definition LevelInstanceTypes.h:127
void SetExternalActors(bool bInExternalActors)
Definition LevelInstanceTypes.h:128
bool UseExternalActors() const
Definition LevelInstanceTypes.h:129
Definition ObjectPtr.h:488