35 lines
1.0 KiB
Lua
35 lines
1.0 KiB
Lua
WidgetLibrary = WidgetLibrary or {}
|
|
|
|
|
|
--- 设置
|
|
---@param widget UUserWidget
|
|
---@param offset float
|
|
function WidgetLibrary.SetWidgetToRightBorder(widget, offset)
|
|
if not widget then return end
|
|
local slot = WidgetLayoutLibrary.SlotAsCanvasSlot(widget)
|
|
slot:SetAnchors({ Minimum = { X = 1, Y = 0 }, Maximum = { X = 1, Y = 0 } })
|
|
slot:SetAlignment({ X = 1, Y = 0 })
|
|
local offsets = slot:GetOffsets()
|
|
slot:SetOffsets({ Left = offset, Right = offsets.Right, Bottom = offsets.Bottom, Top = offsets.Top })
|
|
end
|
|
|
|
--- 为防止被清除做出的全局处理
|
|
function WidgetLibrary.BindButtonClicked(TargetButton, Func, Obj)
|
|
TargetButton.OnClicked:Add(Func, Obj)
|
|
end
|
|
|
|
--- 绑定UI文本
|
|
function WidgetLibrary.TextBlockBindingPropertyText(TargetTextBlock, Func, Obj)
|
|
TargetTextBlock:BindingProperty("Text", Func, Obj)
|
|
end
|
|
|
|
--- 直接绑定按键点击打开WidgetManager的页面
|
|
function WidgetLibrary.ButtonOnClickShowPanel(TargetButton, UIType)
|
|
TargetButton.OnClicked:Add(
|
|
function()
|
|
WidgetManager:ShowPanel(UIType, false)
|
|
end
|
|
)
|
|
end
|
|
|