UWorld* causing issues in DataAsset

I’m creating a c++ child class of UPrimaryDataAsset to save metadata about levels, the idea being that each level will have a matching LevelInfo DataAsset containing information about it.

The class contains variables such as:
FString Name;
FString Description;
UTexture2D* Thumbnail;

However, when I introduce the variable to store a reference to the level asset:

UPROPERTY(EditAnywhere, BlueprintReadWrite)
UWorld* Level;

I get an error when saving the contents of a LevelInfo asset:

Can’t save
D:/ProjectFolder/Content/Maps/Tutorial_Info.uasset:
Graph is linked to object(s) in
external map. External Object(s):
Tutorial_Map Try to find the chain
of references to that object (may take
some time)?

Any ideas? Without this field, all LevelInfo assets save fine.

Just in case someone else stumbles upon this in the future, you can use a TSoftObjectPtr in a scenario like this.

FStruct LevelInfo {
  //FSTRUCT stuff
  UPROPERTY()
  FString Name;

  UPROPERTY()
  FString Description;

  UPROPERTY()
  UTexture2D* Thumbnail;
}

UPROPERTY(EditAnywhere, BlueprintReadWrite)
TSoftObjectPtr<UWorld> Level;

LevelInfo.Name = Level.GetAssetName();
// etc.
1 Like