wyozi / 3d2d-imgui

Immediate mode 3D2D UI for Garry's Mod
MIT License
42 stars 15 forks source link

No cursor + Can't press #22

Closed Nogitsu9 closed 5 years ago

Nogitsu9 commented 5 years ago

When I add a button the cursor doesn't show and I can't even press the button..

function ENT:Draw() self:DrawModel() local ang = self:GetAngles() ang:RotateAroundAxis( self:GetUp(), 180 ) ang:RotateAroundAxis( self:GetRight(), 90 )

local p = tdui.Create() or p
p:Rect(0, 0, 475, 475, Color(58,58,58), _)
p:Text("Chambre 1", "!Coolvetica Rg@600", 237.5, 5)

p:Rect(125, 150, 200, 75, Color(150,58,58), _)
if p:Button("Sonner", "HVH_T600", 125, 150, 200, 75, Color(58,58,58)) then
    self:EmitSound("garrysmod/content_downloaded.wav")
end

p:Cursor()
p:SetUIScale(5)
p:Render(self:GetPos()+self:GetRight()*23.7+self:GetUp()*1.6+self:GetForward()*-23.7, ang, 0.02)

end

wyozi commented 5 years ago

Try storing the p property inside the entity (ie self). Right now you're creating a new one each frame since p is nil at the point where you do local p = tdui.Create() or p

Nogitsu9 commented 5 years ago

Thanks that was just this small detail.. Thanks again !