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

**URL:** <https://forums.unrealengine.com/t/assets-that-are-soft-referenced-by-widget-blueprint-local-variables-are-not-included-in-cooked-build/1668498>\
**Category:** Programming & Scripting\
**Tags:** Cooking, reference, build, unreal-engine, bug-report, Widget, Blueprint, question\
**Created:** [February 5, 2024, 7:44pm UTC](https://forums.unrealengine.com/t/assets-that-are-soft-referenced-by-widget-blueprint-local-variables-are-not-included-in-cooked-build/1668498 "2024-02-05T19:44:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![faizaan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@faizaan](https://forums.unrealengine.com/u/faizaan)\
**Post date:** [February 5, 2024, 7:44pm UTC](https://forums.unrealengine.com/t/assets-that-are-soft-referenced-by-widget-blueprint-local-variables-are-not-included-in-cooked-build/1668498/1 "2024-02-05T19:44:47Z")

</div>

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](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/3/8/338f7f004020545459e1218ac7d88714911dc085.png)

Thanks

---

<div class="post-metadata">

**Author:** ![Chatouille](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/chatouille/32/1194622_2.png) [@Chatouille](https://forums.unrealengine.com/u/Chatouille)\
**Post date:** [February 7, 2024, 2:36pm UTC](https://forums.unrealengine.com/t/assets-that-are-soft-referenced-by-widget-blueprint-local-variables-are-not-included-in-cooked-build/1668498/2 "2024-02-07T14:36:44Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![faizaan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@faizaan](https://forums.unrealengine.com/u/faizaan)\
**Post date:** [February 7, 2024, 7:22pm UTC](https://forums.unrealengine.com/t/assets-that-are-soft-referenced-by-widget-blueprint-local-variables-are-not-included-in-cooked-build/1668498/3 "2024-02-07T19:22:03Z")

</div>

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](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/6/d/26d56cf0d48745cd40069fd7c3335d7ebd12e210.png)

---

<div class="post-metadata">

**Author:** ![Chatouille](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/chatouille/32/1194622_2.png) [@Chatouille](https://forums.unrealengine.com/u/Chatouille)\
**Post date:** [February 8, 2024, 10:16am UTC](https://forums.unrealengine.com/t/assets-that-are-soft-referenced-by-widget-blueprint-local-variables-are-not-included-in-cooked-build/1668498/4 "2024-02-08T10:16:39Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![AlexCarleBHVR](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AlexCarleBHVR](https://forums.unrealengine.com/u/AlexCarleBHVR)\
**Post date:** [February 22, 2024, 4:47pm UTC](https://forums.unrealengine.com/t/assets-that-are-soft-referenced-by-widget-blueprint-local-variables-are-not-included-in-cooked-build/1668498/5 "2024-02-22T16:47:35Z")

</div>

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?
