最简单的绘制脚本!
放入任意界面脚本即可
local NP, jmid = {}
local math_sqrt, math_deg, math_atan2 = math.sqrt, math.deg, math.atan2
local CustomUI = CustomUI
local function getRayLengthAndAngle(x, y, x2, y2)
local dx, dy = x2 - x, y2 - y
local len_sq = dx * dx + dy * dy
if len_sq == 0 then return 0, 0 end
local length = math_sqrt(len_sq)
local angle_deg = math_deg(math_atan2(dy, dx))
if angle_deg < 0 then angle_deg = angle_deg + 360 end
return length, angle_deg
end
local uiT = function(pid, jmid, uiid, x, y, x2, y2)
local w, an = getRayLengthAndAngle(x, y, x2, y2)
CustomUI:SetSize(pid, jmid, uiid, w, 2)
CustomUI:SetPosition(pid, jmid, uiid, x, y)
CustomUI:RotateElement(pid, jmid, uiid, an)
end
local Player_uiid = {}
local Area, Player, Actor = Area, Player, Actor
local GetObj = Area.GetAllObjsInAreaRange
local Player_GetScreenSpacePosV2 = Player.GetScreenSpacePosV2
local Actor_GetPosition = Actor.GetPosition
function NP:OnStart()
jmid = self.gameObject.GetId()
self:AddTriggerEvent(TriggerEvent.GameAnyPlayerEnterGame,function(_, e)
local pid = e.eventobjid
Player_uiid[pid] = {}
self:ThreadWork(function()
local tab, tab2 = {}, {}
local uitab = Player_uiid[pid]
local DoTaskInTime = self.DoTaskInTime
while Player_uiid[pid] do
self:ThreadWait(0.01)
local x, y, z = Actor_GetPosition(Actor, pid)
local range = 200
tab.x, tab.y, tab.z = x - range, y - range, z - range
tab2.x, tab2.y, tab2.z = x + range, y + range, z + range
local pids = GetObj(Area, tab, tab2, ObjType.Player)
local objs = GetObj(Area, tab, tab2, ObjType.Mob)
for _, v in ipairs(objs) do
pids[#pids + 1] = v
end
local Nay = #pids
for i = 1, Nay do
local v = pids[i]
DoTaskInTime(self, function()
if not uitab[i] then
local id = CustomUI:CreateElement(pid, jmid, ElementType.Texture)
CustomUI:SetTexture(pid, jmid, id, "0_10212")
uitab[i] = id
end
local id = uitab[i]
local xx, yy, zz = Actor_GetPosition(Actor, v)
local ux, uy = Player_GetScreenSpacePosV2(Player, pid, xx, yy, zz)
uiT(pid, jmid, id, 800, 0, ux, uy)
end, 0)
end
for i = Nay + 1, #uitab do
CustomUI:SetSize(pid, jmid, uitab[1], 0, 0)
end
end
end)
end)
self:AddTriggerEvent(TriggerEvent.GameAnyPlayerLeaveGame,function(_, e) Player_uiid[e.eventobjid] = nil end)
end
return NP

