2025-07-13 15:47:08 +08:00
|
|
|
local GameplayStatics = import("GameplayStatics")
|
|
|
|
|
local WidgetUtils = {}
|
|
|
|
|
|
|
|
|
|
local function GetHud(wco)
|
|
|
|
|
local pc = GameplayStatics.GetPlayerController(wco, 0)
|
|
|
|
|
if pc == nil then return end
|
|
|
|
|
return pc:GetHud()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function WidgetUtils.Show(wco, widget_name)
|
|
|
|
|
local hud = GetHud(wco)
|
|
|
|
|
if not hud then return end
|
2025-08-19 03:23:36 +08:00
|
|
|
return hud:BP_PushWidget(widget_name)
|
2025-07-13 15:47:08 +08:00
|
|
|
end
|
|
|
|
|
|
2025-08-19 03:23:36 +08:00
|
|
|
function WidgetUtils.Close(wco, widget_name)
|
2025-07-13 15:47:08 +08:00
|
|
|
local hud = GetHud(wco)
|
|
|
|
|
if not hud then return end
|
|
|
|
|
return hud:PopWidget(widget_name)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return WidgetUtils
|