Possible to declare a static texture2d that can be updated via blueprint?

Hi I am trying to set an icon for say a weapon. I have an array of the weapon classes but I would like to access the icon texture for my hud without creating an instance of that weapon. say because I am create and destroy the weapons as you equip them, so something like:

MyWeapon::RadialIcon

would be perfect but this wont compile:

UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = “Bear”)
static UTexture2D* RadialIcon;

nor

UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = “Bear”)
static const UTexture2D* RadialIcon;

any ideas? is it even possible?

you could use a UDataAsset to store icons, that you can also access from your blueprinted weapons easily.

Hi,

I recently tried exactly that. Working Solution:

UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = “Bear”)
TAssetPtr<UTexture2D> RadialIcon;

In Blueprint: Get Class -> Get Class Defaults -> RadialIcon -> Resolve Asset

What I also tried:

Using a UTexture2D* with GetClassDefaults doesn’t work. On the AnswerHub, someone from Epic pointed out that this is normal behaviour because the UTexture2D reference cannot be guaranteed to be read-only in Blueprint.

Workaround is to wrap the UTexture2D* in a USTRUCT. But getting the UTexture2D* from the struct using getclassdefaults and then trying to pass the reference gave me errors along the lines of " graph is linked to external private object". Long story short, use the AssetPointer

I just need to access the asignment of the object on the bp, dont care for it on the graph. Basically I need something equivalent to static functions in udk

k got it, you can do this:

ExampleClass.h

UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = “Bear”)
UTexture2D* RadialIcon;

FORCEINLINE UTexture2D* GetRadialIcon() { return RadialIcon; }

and then access it like:

ExampleClass.GetDefaultObject()->GetRadialIcon();