Is it possible to reference level in blueprint?

I want to add a property to a class, which can be set to a Level resource in blueprint editor. But making an UWorld * property allows me to set Level as a value to a property, but I can not save blueprint.

Can I somehow retain a level selection popup, but store only a level name - actually it would be enough for my task.

Hello ,

What type of message are you getting when you try to save the blueprint? I made a C++ class based off Actor that has a UPROPERTY with the specifier EditAnywhere and the type of UWorld*. After setting the value to my new map in the editor, I was able to save without any issues.

Here is the error. I think it is because field is declared in GameInstance blueprint.

Was this blueprint duplicated or created as a child of another blueprint? Have you copy/pasted any blueprint nodes from one blueprint to another? There can sometimes be some reference problems that cause this error message to appear. One possible way to narrow it down would be to save a copy of the entire project and then start deleting any suspecting nodes one by one and attempting to save to see if you receive the same message.

No, everything was created from scratch. No copies, no duplicates.

Can you post the code for your class that is adding this property? It would be helpful to have that information as the problem may be there.

Here it is
, try to open BP_MyGameInstance and set level there.

I think the whole idea will not work. Because referencing level requires it’s loading when BP is instantiated. So there would be many levels loaded which is not permitted.

My original goal was to gather level names by selecting them from drop down menu. I really do not need references to the UWorlds.

I believe you may be right. If you’re going to be using a workflow where you know the names of the maps at all times, it may be best to use an enumeration or an array of FNames to store the names of the level. You will need to hardcode the names in however, to match the level names. Would this option work for you?

Hi ,
I actually found the solution, I should use TAssetPtr for this. Like

UPROPERTY(Category = "Level", EditAnywhere, BlueprintReadOnly)
TArray<TAssetPtr<UWorld>> Levels;

Is solves the problem of setting level references in the editor. But another problem appears - I can not use the value of this property directly form blueprint. Need to write another function which will return FName of FPackageName::ObjectPathToObjectName of referenced asset.

It would be cool if Epics can integrate TAssetPtr usage to their apis. Like LoadLevel having version with TAssetPtr parameter. I think AssetPtr’s can be very handy.