通过3D2D脚本创建按钮不起作用

时间:2019-01-22 09:32:36

标签: lua garrys-mod

我一直试图弄清楚如何在3D2D上设置按钮。我创建了该脚本的一个版本,该版本并未在控制台中引起任何错误,但仍无法实现我想要的功能(将鼠标悬停在它们上面时,将按钮变成蓝色。这是我的摘要)我在做:

function ENT:Draw()

self:DrawModel()

if LocalPlayer():GetEyeTrace().Entity then 
    if LocalPlayer():GetEyeTrace().Entity == self then
    localTrace = self:WorldToLocal( LocalPlayer():GetEyeTrace().HitPos ) 
    end
end

if ( localTrace.x > -145 and localTrace.x < -145 + 145 ) and ( localTrace.y > 100 and localTrace.y < 100 + 90 ) then
    self:SetLookStart(1)
else
    self:SetLookStart(0)
end

if ( localTrace.x > -145 and localTrace.x < -145 + 145 ) and ( localTrace.y > 100 and localTrace.y < 100 + 90 ) then
    self:SetLookEmpty(1)
else
    self:SetLookEmpty(0)
end



local MixerAng = self:GetAngles()

local MixerPos = self:GetPos() + ( self:GetAngles():Right() * 15 )

local LimeJuice = self:GetLimeJuice()

local LookStart = self:GetLookStart()

local LookEmpty = self:GetLookEmpty()

MixerAng:RotateAroundAxis(self:GetAngles():Forward(),90)

cam.Start3D2D(MixerPos , MixerAng , .1)

    draw.RoundedBox(0,-150,-200,300,400,Color(88, 111, 255, 200))

    draw.OutlinedBox(-150,-200,300,400, 10, Color(139, 220, 255))

    draw.OutlinedBox(-150,-200,300,300, 10, Color(139, 220, 255))

    draw.OutlinedBox(-150,-100,300,300, 10, Color(139, 220, 255))

    draw.OutlinedBox(-150,90,155,110, 10, Color(139, 220, 255))

    draw.SimpleText("Ingredients", "BaseFont",0,-150,Color(0,0,0),1,1)

    if LimeJuice > 0 then
        draw.SimpleText("Lime Juice: " .. LimeJuice .. "ml", "s_BaseFont",0,-50,Color(0,0,0),1,1)
    end

    draw.SimpleText("Empty", "s_BaseFont",-70,145,Color(0,0,0),1,1)

    draw.SimpleText("Start", "s_BaseFont",70,145,Color(0,0,0),1,1)

    if LookStart == 1 then
        draw.RoundedBox(0, 0,100, 145, 90, Color(139,220,255,150))
    end

    if LookEmpty == 1 then
        draw.RoundedBox(0, -145,100, 145, 90, Color(139,220,255,150))
    end

cam.End3D2D()

结束

0 个答案:

没有答案