UMG菜单锚生成出来的UI 为啥会自带一层黑色背景,怎么去掉
- Modify the UMenuAnchor in the UE5.x engine
- 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.
protected:
virtual TSharedRef RebuildWidget() override;
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=“Menu Anchor”)
bool bShowMenuBackground = false;
TSharedRef UMyMenuAnchor::RebuildWidget()
{
TSharedRef Widget = Super::RebuildWidget();
if (MyMenuAnchor.IsValid())
{
if (IMenuHost* MenuHost = MyMenuAnchor.Get())
{
MenuHost->bShowMenuBackground = bShowMenuBackground;
}
}
return Widget;
}