PGRData/Script/matrix/xguide/node/XGuideFocusOnPanelNode.lua

68 lines
2 KiB
Lua
Raw Normal View History

2024-09-01 20:49:41 +00:00
---@class XGuideFocusOnPanelNode : XLuaBehaviorNode
---@field AgentProxy XGuideAgent
local XGuideFocusOnPanelNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "GuideFocusOn", CsBehaviorNodeType.Action, true, false)
--初始化数据
function XGuideFocusOnPanelNode:InitNodeData()
if not self.Node.Fields then
self.Fields = nil
return
end
self.Fields = {}
local fields = self.Node.Fields.Fields
2024-09-01 20:49:41 +00:00
for _, v in pairs(fields) do
2024-09-01 20:49:41 +00:00
if v.FieldName == "EulerAngles" or v.FieldName == "SizeDelta" then
self.Fields[v.FieldName] = v
else
self.Fields[v.FieldName] = v.Value
end
end
end
--聚焦Ui
function XGuideFocusOnPanelNode:OnAwake()
if self.Fields == nil then
self.Node.Status = CsNodeStatus.ERROR
return
end
if self.Fields["UiName"] == nil or self.Fields["Transform"] == nil then
self.Node.Status = CsNodeStatus.ERROR
return
end
self.UiName = self.Fields["UiName"]
self.Transform = self.Fields["Transform"]
self.AnyClick = self.Fields["AnyClick"]
local eulerAngles = self.Fields["EulerAngles"]
self.EulerAngles = CS.UnityEngine.Vector3(eulerAngles.X, eulerAngles.Y, eulerAngles.Z)
self.PassEvent = self.Fields["PassEvent"]
2024-09-01 20:49:41 +00:00
local sizeDelta = self.Fields["SizeDelta"]
self.SizeDelta = CS.UnityEngine.Vector2(sizeDelta.X, sizeDelta.Y)
end
function XGuideFocusOnPanelNode:OnEnter()
2024-09-01 20:49:41 +00:00
self.AgentProxy:FocusOn(self.UiName, self.Transform, self.EulerAngles, self.PassEvent, self.SizeDelta)
end
function XGuideFocusOnPanelNode:OnGetEvents()
return { CS.XEventId.EVENT_GUIDE_CLICK_BTNPASS, CS.XEventId.EVENT_GUIDE_ANYCLICK }
end
function XGuideFocusOnPanelNode:OnNotify(evt)
if evt == CS.XEventId.EVENT_GUIDE_CLICK_BTNPASS then
self.Node.Status = CsNodeStatus.SUCCESS
elseif self.AnyClick and evt == CS.XEventId.EVENT_GUIDE_ANYCLICK then
self.Node.Status = CsNodeStatus.SUCCESS
end
end