# Widget Blueprints that are only referenced in code are not cooked correctly

**URL:** <https://forums.unrealengine.com/t/widget-blueprints-that-are-only-referenced-in-code-are-not-cooked-correctly/304288>\
**Category:** Blueprint\
**Tags:** runuatbat, unreal-engine, Packaging, Blueprint, CPP, question\
**Created:** [January 18, 2015, 2:11pm UTC](https://forums.unrealengine.com/t/widget-blueprints-that-are-only-referenced-in-code-are-not-cooked-correctly/304288 "2015-01-18T14:11:46Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_55d41bed](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_55d41bed](https://forums.unrealengine.com/u/anonymous_user_55d41bed)\
**Post date:** [January 18, 2015, 2:11pm UTC](https://forums.unrealengine.com/t/widget-blueprints-that-are-only-referenced-in-code-are-not-cooked-correctly/304288/1 "2015-01-18T14:11:46Z")

</div>

Hi all, I recently started using UMG for my project, and have some widgets that are loaded and created from C++, rather than Blueprints. But, for some reason it looks like they won’t load correctly when I try to run my packaged game. But, everything works fine in the editor. I was able to verify that the uassets for these blueprints are being copied correctly after the Cook, and they’re definitely there, so I’m puzzled as to what the issue could be.

Here is an excerpt from the logs when I start seeing these errors:

```
[2015.01.18-13.54.08:668][0]LogUObjectGlobals:Warning: Failed to find object 'Blueprint /Game/UI/Nameplate.Nameplate'
[2015.01.18-13.54.08:668][0]Error: CDO Constructor: Failed to find Blueprint'/Game/UI/Nameplate.Nameplate'
[2015.01.18-13.54.08:669][0]LogUObjectGlobals:Warning: Failed to find object 'Blueprint /Game/UI/DamageText.DamageText'
[2015.01.18-13.54.08:669][0]Error: CDO Constructor: Failed to find Blueprint'/Game/UI/DamageText.DamageText'
[2015.01.18-13.54.08:669][0]LogTemp:Warning: Instansiating medium armor
[2015.01.18-13.54.08:756][0]LogTemp:Warning: Instansiating medium armor
[2015.01.18-13.54.08:760][0]LogUObjectGlobals:Warning: Failed to find object 'Blueprint /Game/UI/PreGame/MainMenuUI.MainMenuUI'
[2015.01.18-13.54.08:760][0]Error: CDO Constructor: Failed to find WidgetBlueprint'/Game/UI/PreGame/MainMenuUI.MainMenuUI'
[2015.01.18-13.54.08:769][0]LogUObjectGlobals:Warning: Failed to find object 'Blueprint /Game/UI/PreGame/Lobby.Lobby'
[2015.01.18-13.54.08:769][0]Error: CDO Constructor: Failed to find WidgetBlueprint'/Game/UI/PreGame/Lobby.Lobby'
[2015.01.18-13.54.08:769][0]LogTemp:Warning: Shield stopped
[2015.01.18-13.54.08:848][0]LogUObjectBase:Warning: -------------- Default Property warnings and errors:
[2015.01.18-13.54.08:848][0]LogUObjectBase:Warning: Error: CDO Constructor: Failed to find Blueprint'/Game/UI/Nameplate.Nameplate'
[2015.01.18-13.54.08:848][0]LogUObjectBase:Warning: Error: CDO Constructor: Failed to find Blueprint'/Game/UI/DamageText.DamageText'
[2015.01.18-13.54.08:848][0]LogUObjectBase:Warning: Error: CDO Constructor: Failed to find WidgetBlueprint'/Game/UI/PreGame/MainMenuUI.MainMenuUI'
[2015.01.18-13.54.08:848][0]LogUObjectBase:Warning: Error: CDO Constructor: Failed to find WidgetBlueprint'/Game/UI/PreGame/Lobby.Lobby'

```

Here’s how I am loading them in C++:

```
	static ConstructorHelpers::FObjectFinder<UBlueprint> LobbyBlueprintObject(TEXT("WidgetBlueprint'/Game/UI/PreGame/Lobby.Lobby'"));
	if (LobbyBlueprintObject.Object != NULL)
	{
		LobbyWidgetClass = (UClass*)LobbyBlueprintObject.Object->GeneratedClass;
	}

```

I’ve tried packaging through the editor, with both PAK enabled and disabled, and have also tried packaging using RunUAT and the command below, also with the PAK option enabled and disabled, and every time I seem to fail with the same issue. I have also tried explicitly adding the content directory where these are stored as a -CookDir option, and that didn’t help.

```
RunUAT BuildCookRun -project="%CD%\Moonstorm.uproject" -Build -noP4 -platform=Win64 -clientconfig=Development -serverconfig=Development -pak -nocompile -cook -maps=AllMaps -stage -archive -CookDir="%CD%\Content\UI" -archivedirectory="%CD%\Out"

```

Does anyone have any idea what I could be doing wrong here? Thanks!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_55d41bed](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_55d41bed](https://forums.unrealengine.com/u/anonymous_user_55d41bed)\
**Post date:** [January 19, 2015, 12:39am UTC](https://forums.unrealengine.com/t/widget-blueprints-that-are-only-referenced-in-code-are-not-cooked-correctly/304288/2 "2015-01-19T00:39:43Z")

</div>

Not necessarily a solution, but I ended up just creating the widgets from BPs and assigning the UUserWidget pointer in my C++ class. This is not ideal, because it ends up with me either having to create a parent BP for all my BPs, or have a lot of repetition that I could otherwise avoid.

---

<div class="post-metadata">

**Author:** ![LemonLime123\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@LemonLime123\_1](https://forums.unrealengine.com/u/LemonLime123_1)\
**Post date:** [February 2, 2015, 6:48pm UTC](https://forums.unrealengine.com/t/widget-blueprints-that-are-only-referenced-in-code-are-not-cooked-correctly/304288/3 "2015-02-02T18:48:11Z")

</div>

Anybody figure out the reason behind this?

---

<div class="post-metadata">

**Author:** ![Martin\_Esquirol](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Martin\_Esquirol](https://forums.unrealengine.com/u/Martin_Esquirol)\
**Post date:** [February 27, 2015, 9:17am UTC](https://forums.unrealengine.com/t/widget-blueprints-that-are-only-referenced-in-code-are-not-cooked-correctly/304288/4 "2015-02-27T09:17:51Z")

</div>

Hello, try using UClass instead of UBlueprint for your FObjectFinder, it worked well for me. You also have to change the path of your blueprint by adding ‘\_C’ . for your code that would give this

```
static ConstructorHelpers::FObjectFinder<UClass> LobbyBlueprintObject(TEXT("/Game/UI/PreGame/Lobby.Lobby_C"));
if (LobbyBlueprintObject.Object != NULL)
{
LobbyWidgetClass = LobbyBlueprintObject.Object;
}
```

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_70973a59](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_70973a59](https://forums.unrealengine.com/u/anonymous_user_70973a59)\
**Post date:** [June 27, 2015, 8:39am UTC](https://forums.unrealengine.com/t/widget-blueprints-that-are-only-referenced-in-code-are-not-cooked-correctly/304288/5 "2015-06-27T08:39:34Z")

</div>

Wow, it’s amazing!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_f1d9eaa9](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_f1d9eaa9](https://forums.unrealengine.com/u/anonymous_user_f1d9eaa9)\
**Post date:** [July 23, 2015, 7:16am UTC](https://forums.unrealengine.com/t/widget-blueprints-that-are-only-referenced-in-code-are-not-cooked-correctly/304288/6 "2015-07-23T07:16:02Z")

</div>

> Wow, it’s amazing!  
> Not sure if this is sarcasm…

Base native classes are derived directly from UUserWidget. Base class is set in blueprints with Graph \> Class settings. Works fine in editor, but refuses to package (Class not found errors). Tried casting to UBlueprint and UClass with and without \_C suffix.  
**Anyone else been here and solved this problem (was on 4.7.6, now on 4.8.2).**

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_f1d9eaa9](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_f1d9eaa9](https://forums.unrealengine.com/u/anonymous_user_f1d9eaa9)\
**Post date:** [July 24, 2015, 9:08am UTC](https://forums.unrealengine.com/t/widget-blueprints-that-are-only-referenced-in-code-are-not-cooked-correctly/304288/7 "2015-07-24T09:08:59Z")

</div>

Doh! - I’m my case I had neglected to explicitly include the blueprints directory so the (unreferenced except in native code) blueprints weren’t being cooked.
