Assets that are Soft Referenced by Widget Blueprint Local Variables are not included in cooked build

There seems to be some inconsistent behaviour with how .uassets are included in the cooked build based on the type of blueprint variable/reference.
If a SoftClassReference is a class variable (class defaults), then the referenced asset is included in the cooked build.
If a SoftClassReference is a local variable, then the referenced asset is not included in the cooked build.
If a HardClassReference is a local variable, then the referenced asset is included in the cooked build.
So, it seems like the combination of a soft class reference through a blueprint local variable causes the asset to not be included. Is this a known issue or expected behavior? Are there any solutions/workarounds to this?
image

Thanks

Seems logical to me.

The cooker doesn’t run your entire game to know what is gonna be referenced during runtime, so it can only know based on CDO’s (class defaults).

Local variables are only relevant when function is executed, ie. at runtime. Generally they are used to store temporary values, and not as constants. Using it as a constant is just like using a “Make soft class path” node and inputting a string path directly. Neither would be picked up by the cooker’s reference collector.

Either use a hard ref or, if you really need soft, move it to a global variable so the collector can pick up the soft ref from class defaults.

1 Like

Thanks for the reply. I am actually trying to use the soft reference inside of a Blueprint Function Library which only has local variables, no class variables. Do you have any suggestions for getting around this?
image

In C++ you could make an intermediate child class of UBlueprintFunctionLibrary, with extra variables so you could add your soft ref as a class variable there.

Without C++ I can’t think of anything good - you could use data asset to reference the widget, or simply force-cook the widget in packaging settings, but in both cases that means maintaining the reference in two places, which is meh…

I’m not super familiar with DataAssets or PrimaryAssets, but maybe you can reference the widget class in a data asset, then in your BPFL load the data asset and retrieve the widget class within…

1 Like

Except that the cooker does run through the references, since it will picks on class default soft reference variables (so Blueprint only) as well as local variables that are hard references. The behavior is so specific it truly looks like a bug?

1 Like