Hot-reload causes DataAssets to become corrupted/deleted

I have a USceneComponent subclass with a TArray property. MyDataAsset is a UDataAsset subclass used for assigning arbitrary sets of attributes to my objects within the editor.

So that we’re clear, let’s assume that my UDataAsset subclass looks like this:

UCLASS(BlueprintType)
class MYGAME_API MyDataAsset: public UDataAsset
{
	GENERATED_BODY()

public:
	MyDataAsset(const FObjectInitializer& ObjectInitializer);

	UPROPERTY(EditAnywhere, BlueprintReadOnly)
	FString Title;

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Meta = (Multiline = "true"))
	FText Description;

	UPROPERTY(EditAnywhere, BlueprintReadOnly)
	UTexture2D* Icon;
};

And my USceneComponent subclass:

UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
class MYGAME_API UComponentWithDataAssets : public USceneComponent
{
	GENERATED_BODY()

public:	
	UComponentWithDataAssets(const FObjectInitializer& ObjectInitializer);

    // ... Rest of class body omitted

	UPROPERTY(EditAnywhere, BlueprintReadOnly)
	TArray<MyDataAsset*> ListOfDataAssets;
};

If I do the following:

  1. Add a UComponentWithDataAssets to one of my Blueprint actors
  2. Populate ListOfDataAssets with some DataAssets
  3. Place the actor in the level
  4. Recompile code, triggering a hot-reload
  5. Close the editor

I’m prompted to save whichever DataAssets I placed in the list. If I do so and reopen the editor, those DataAssets are now missing from the Content Browser, and all elements of my ListOfDataAssets property contain None.

If I navigate to the system folder where the .uasset files for my DataAssets, the files are still there, but are about half of their original size.

Platform: Windows 8.1 x64
Engine version: 4.7.6

Hey -

I’m trying to test this and I’m not sure if I’m getting the same result. Is there anything in the source files for these classes? Can you post the full classes for your DataAsset and SceneComponent classes? What exactly are you populating the array with?

Hi ,

I’ve been able to replicate the issue in a small test project. I suspect that this is again related to the fact that my components have subcomponents.

The TArray property belongs to a component nested two levels deep, like so:

 MyActor
     |-- USceneComponent
             |-- ParentComponent
                     |-- ChildComponent    // Property belongs to this component

When I manage to hot-reload code changes without it crashing, and close the editor, I’m prompted to save the data assets. If I do, they are corrupted and no longer show up in the browser.

Hi ,

Were you able to observe the issue?

Hey -

How exactly are you creating the DataAssets inside the editor? When I opened the project I found that the three DataAssets already included go missing if the project is closed after a hot reload, however if I create a new DataAsset based on MyDataAsset then this new asset will persist after a hot reload/editor restart.

Hi ,

I created the first DataAsset in the usual way via the content browser. Subsequent ones were created by right-clicking the initial one and selecting “Duplicate”. Perhaps it might have something to do with the fact that I duplicated them rather than creating them from scratch?

Also please note that the DataAssets only disappear if you add them to the array in the BP_TestActor Blueprint. If you create one and don’t hook it up to anything, in my experience it won’t be affected.

Hey -

After additional testing with the project you submitted I don’t have the DataAssets disappear any longer. I was testing the two blueprints and added new data assets to the array of the parent blueprint and triggered a hot reload. After doing so I was not prompted to resave them when I closed the project and they were still there when I opened again. I did bug the original behavior I mentioned previously.

Cheers

Hello !
I have the same issue in 4.15. Reprosteps are very simple:

  1. Create your dataasset class derived from dataasset;

  2. Add some properties to your dataasset;

  3. Compile, run editor, create dataasset object from your dataasset class;

  4. Fill some properties;

  5. Go back to source and add new properties to your dataasset;

  6. Compile → Hot Reload;

Now we have different behaviors:
Sometimes dataasset objects dissapears after hot reload, sometimes after restart of editor, sometimes you see new object in content explorer with the same name as your dataasset object but with postfix “_hotreload1234” and after that data disappearing again on restart.

So… The problem is definitely there… And it has different behaviors from time to time. We really need to fix this.

Hey -

I followed the steps you provided and did not see the data assets disappear. One bit of behavior I did notice was that if the data asset was open in the editor at the time of the hot reload, the float and int32 properties showed as “Multiple Values”. However closing and reopening the asset in the editor restored the shown values to what was set before the hot reload.

If you’re able to reproduce your behavior in a new project, please provide a copy of the project to help me test on my end.