We are encountering a problem involving Data Layers and the actors associated with them, related to their loading and unloading behavior.
The Data Layer is assigned to both the World Data Layers and the actor directly. Although the actor is meant to be unloaded and hidden, it continues to appear and remain visible during runtime.
To replicate the issue:
Place the actor into the level.
Add the Data Layer to the World Data Layers.
Manually add the Data Layer to the actor through the details panel.
Note: This bug happens randomly and can’t always be reproduced. Actors that work at first may stop functioning after some time.
Verified Observations
The actors display the correct Data Layers in the details panel.
It appears that the Actor Descriptions in the World Partition for these actors are not being updated with the appropriate Data Layers.
Can you provide a project that demonstrate the problem? We would also need to know when the problem happens. Is it in the editor or the packaged project?
I think the issue comes from the fact that the Level in which you are adding an actor to a Data Layer doesn’t contain the DataLayer asset inside the WorldDataLayers of that Level.
If you make sure to have the Data Layer in the list of Data Layers for that Level, this should not be an issue anymore.
In fact, if you edit the Level Instance in-place (the sub-level) directly from the main world, then drag the an actor from that Level instance onto a Data Layer of the main world, it will add the Data Layer Instance in the WorldDataLayers of the sub-level if missing.
The initial idea was that it should be possible to test a sub-level without the main world, so it should also contain the list of Data Layers in its WorldDataLayers.
That being said, it looks like directly modifying the DataLayer Assets array of an actor from the details panel is not properly handled.
We need to validate if what you are proposing (force load) won’t cause any issues elsewhere.
Meanwhile, you can simply make sure to manually add the Datalayer in the WorldDataLayers of you sub-level or use the in-place LevelInstance editing combined with drag & drop in the DataLayer Outliner.
We are now working on reproducing this bug in a vanilla project, having stepped through and understood what happens in our project.
Steps and causes:
Open the Level Asset for a Level Instance Actor without loading any other level.
Find an actor instance in the level that has a Data Layer set on it and make a small edit (move it, for example). This data layer should not be on the level itself, meaning the data layer asset has not been loaded.
Save the actor instance.
Inside of FWorldPartitionActorDesc::Init line 131, this calls InActor->GetDataLayerAssets(bIncludeExternalDataLayerAsset).
This results in the DataLayers in the WorldPartionaActorDesc getting blown away.
Locally we are experimenting with replacing the two functions passed into the Algo::TransformIf with !DataLayerAsset.IsNull() for the predicate and DataLayerAsset.LoadSyncrhonous() for the transform function.