local startPos, endPos--射线检测起点与终点
local InteractButton = 100078--互动按钮
local InformationBar = 100080--互动物品介绍控件
local _DetectedElement = 0--检测到的元件
local GuideInstanceID = 304--一个指引元件做的互动提示
    Name = "台灯",ID = 302,Inf = "这是一盏台灯。"
    Name = "盒子",ID = 303,Inf = "一个神秘的盒子。"
    Name = "书桌",ID = 313,Inf = "整洁的桌子。"
function GameClient:OnStart()
    TimerManager:AddLoopTimer(0.1, function ()
        local startPos = Character:GetPosition(curPlayerId)--设置射线检测起点
        local endPos = startPos + Character:GetForward(curPlayerId) * 500--设置射线检测终点
        _DetectedElement = PlayInteractive:GetHitElementWithRaycast(startPos, endPos)--射线检测玩家前方5米内的元件
        local IsInteractElement = false--是否检测到互动物品
        for _, value in ipairs(ItemArray) do--遍历可互动物品数组
            if _DetectedElement == value.ID then--判断是否是可互动物品
                IsInteractElement = true--是可互动物品
                InteractItem = value--设置可互动物品信息
        if IsInteractElement then
            Guide:SetGuideVisible(GuideInstanceID,true)--显示指引器
            Guide:SetGuideLabelText(GuideInstanceID,InteractItem.Name)--设置指引器文字为物品名
            Element:SetPosition(GuideInstanceID, Element:GetPosition(_DetectedElement) + Engine.Vector(0,0,200), Element.COORDINATE.World)--设置指引器位置
            UI:SetVisible({InteractButton},true)--显示互动按钮
            UI:SetText({InformationBar},InteractItem.Inf)--设置信息栏文字
            Guide:SetGuideVisible(GuideInstanceID,false)--隐藏指引器
            UI:SetVisible({InteractButton},false)--隐藏互动按钮
            UI:SetVisible({InformationBar},false)--隐藏信息栏
    UI:RegisterPressed(InteractButton,function(Iteam,PosX,PosY)
        UI:SetVisible({InformationBar},true)