I am currently trying to make a custom UOverlay widget with default content. The idea is essentially to make a specialized menu item that I can spawn without having to do too much work on setting each individual menu item’s unique properties. Something I can easily mass spawn into a scrollbox or something.
Based on some other information I found, I am trying to use the RebuiltWidget function, and the following code seems to do what I want:
TSharedRef<SWidget> UBK_UIWidget_ItemContainerSimple::RebuildWidget()
{
TSharedRef<SWidget> ItemContainerWidget = Super::RebuildWidget();
if (!ItemIconContainer)
{
ItemIconContainer = NewObject<UImage>(UImage::StaticClass());
if (ItemIconContainer)
{
ItemIconContainer->Brush.ImageSize = FVector2D(64.f, 64.f);
ItemIconSlot = AddChildToOverlay(ItemIconContainer);
}
}
return ItemContainerWidget;
}
And the corresponding lines in the .h file:
UPROPERTY()
UImage* ItemIconContainer;
UPROPERTY()
UOverlaySlot* ItemIconSlot;
With this, it does create the UImage whenever placed (without any crashes), but when I try to save it, it cannot save the package due to the generated UImage. How can I make it so that my widget can be saved normally if I place a menu-item? I should note that at this point, I have only extended from the UMG UOverlay class; I have not yet touched any of the slate classes.