Packaging fails to package widget blueprints referenced from code

Hi,

repro steps:

  1. Create new project based on “first person” c++ example.

  2. In content folder create widget (AddNew->UI->WidgetBlueprint) and name it W_UnitWidget.

  3. Open VS, and go to [ProjectName]Character.cpp file.

  4. In constructor at the end add this code:

    static ConstructorHelpers::FObjectFinderMyObj(TEXT(“WidgetBlueprint’/Game/W_UnitWidget.W_UnitWidget’”));
    if (MyObj.Object && GEngine)
    {
    GEngine->AddOnScreenDebugMessage(-1, 14.f, FColor::Red, “widget found”);
    }

Remember to put aproppriete widget reference in MyObj contructor.

  1. Compile. After hot reload hit play in editor or play in standalone widow. Debug message “widget found” appears. Our widget was properly foun.
  2. Go to File->Package project->Packageing settings. Check “Full rebuild”
  3. Package project (File->Package project->Widnows->Windows 64 bit)
  4. After packageing is done go to packaged project and run game
  5. Game will prompt that W_UnitWidget was not found

cheers

Hi Buyaka,

Thank you for pointing this out to us. I was able to reproduce what you described using your repro steps (very clear, thank you!), and have submitted a report of my observations to have this investigated further (UE-21466).

Not a bug, the WidgetBlueprint is an editor only class. You can tell because it’s in a module in the Editor directory. UBlueprints should’ve been and hopefully will in the future. You need to reference the generated UClass instead, the “_C” object that’s generated when you compile a blueprint, instead of the WidgetBlueprint. e.g.

"Class’/Game/W_UnitWidget.W_UnitWidget_C’

Hi guys,

thanks for Your answers. Hmm… I think I have found similiar problem, this time with regular blueprint (not UserWidget). Repro steps are almost identical:

  1. Create new project based on “first person” c++ example.

  2. In content folder create blueprintt (AddNew->BlueprintClass), inherit it from Actor and name it BP_MyBP.

  3. Open VS, and go to [ProjectName]Character.cpp file.

  4. In constructor at the end add this code:

    static ConstructorHelpers::FObjectFinderMyObj(TEXT(“Blueprint’/Game/BP_MyBP.BP_MyBP’”));
    if (MyObj.Object && GEngine)
    {
    GEngine->AddOnScreenDebugMessage(-1, 14.f, FColor::Red, “blueprint found”);
    }

Remember to put aproppriete widget reference in MyObj contructor.

  1. Compile. After hot reload hit play in editor or play in standalone widow. Debug message “blueprint found” appears. Our widget was properly found.
  2. Go to File->Package project->Packageing settings. Check “Full rebuild”
  3. Package project (File->Package project->Widnows->Windows 64 bit)
  4. After packageing is done go to packaged project and run game
  5. Game will prompt that BP_MyBp was not found

conslusion is that this issue is not limited to Widgets but to all blueprint classes. Most likely the problem here is that code posted here is executed very early and engine maybe not initialized at this point. If I move this code to other consttructor that runs AFTER begin play event it works as expected.

cheers

This is the same result that Nick mentioned. If you instead use the generated class, everything should work fine.

static ConstructorHelpers::FObjectFinderMyObj(TEXT("/Game/BP_MyBP.BP_MyBP_C"));