UDataAsset vs Blueprintable UObject

A BlueprintType Data Asset

Dear Stefan,

[FONT=Comic Sans MS]Welcome to the forums Stefan!

I’ve used both Data Assets and UObjects for storing data as you are describing, and I’ve used both methods pretty extensively in several different code bases.

The only immediate issue I had with Data Assets vs UObject Blueprints was that I could not store a variable created in BP to a UDataAsset.

For a system as fundamental as inventory, its important that the rest of your team be able to refer to your items in BP!

So you can correct the only short-coming of a UDataAsset by adding BlueprintType to it:



/*
  By Rama
*/
#pragma once

#include "ActionTypes.generated.h"

UCLASS(BlueprintType) //<~~~ So can create vars of this type in BPs 
class UActionTypes : public UDataAsset
{ 
	GENERATED_BODY()
public:  
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Action Types")
	TArray<FString> ActionTypes;
	
};



**UDataAsset**

I personally feel the UDataAsset is more light-weight and definitely has a **cleaner UI** than a UObject Blueprint for game assets that are strictly **data-only** and do not have any logic to them.

Therefore my answer to your question is a **BlueprintType UDataAsset** so people using BP can still make ptrs to your fundamental data type but the UI is as clean as possible for a strictly data-only game asset :)

Neat Icon!

Entertainingly enough, there is already a neat icon for Data assets as BP variables in UE4, though it does not seem that you can create such variables until you add BlueprintType as I show above.

Pic 1:

Because I made the UDataAsset BlueprintType as shown above (C++), I can now create a BP var to it in my level BP.

974f1edc0fbf4542f63cbe949f288a6120b69e02.jpeg

Pic 2:

And because I made it the blue kind (an object ptr not a class type)

I can now set the BP-created variable in my Level BP defaults (Window->Class Defaults)

1e56f7308cb5a1b928bedc186ef35683af1b73a8.jpeg

Enjoy!

:slight_smile:

Rama

2 Likes