ue5.4 UMG菜单锚生成出来的UI 为啥会自带一层黑色背景,怎么去掉

UMG菜单锚生成出来的UI 为啥会自带一层黑色背景,怎么去掉

  1. Modify the UMenuAnchor in the UE5.x engine
  2. Add a custom UMyMenuAnchor

Choose either of the above methods.

The modification methods are the same for both. Below is the modification for method 2.

//MyMenuAnchor.h

protected:
virtual TSharedRef RebuildWidget() override;

public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=“Menu Anchor”)
bool bShowMenuBackground = false;

//MyMenuAnchor.cpp

TSharedRef UMyMenuAnchor::RebuildWidget()
{
TSharedRef Widget = Super::RebuildWidget();

if (MyMenuAnchor.IsValid())
{
    if (IMenuHost* MenuHost = MyMenuAnchor.Get())
    {
        MenuHost->bShowMenuBackground = bShowMenuBackground;
    }
}

return Widget;

}