wyozi / 3d2d-imgui Goto Github PK
View Code? Open in Web Editor NEWImmediate mode 3D2D UI for Garry's Mod
License: MIT License
Immediate mode 3D2D UI for Garry's Mod
License: MIT License
Eg. make it possible to change 3d2d scale without having to resize all individual draw calls. Should this also affect fonts? #10
the link you provide in the installation topic gives an 404 ๐ญ
So i am using a button on a entity and when i have 2 entities the buttons mix themselves, so 1 controls 2 and 2 controls 1. If that could be fixed i would really apreciate! Thanks!
First, I'd like to thank you for this little bit of gold you've made. It's solved a great number of issues.
I'm making a 3d2d gui that's on the viewmodel. The buttons highlight when when you scroll over them, but clicking does nothing.
Any idea on how to fix this?
To allow using stencil for only one rectangle for example.
I want to make the button give the player ammo, or a weapon, I'm currently running the script in shared.lua and I tried making the button part serverside but it still doesn't work. No errors, but nothing happens when I press the button. ( The RunConsoleCommand works just fine tho). Sorry for bothering again but I've actually tried everything I could think of.
self.p = self.p or tdui.Create()
local p = self.p
local ply = LocalPlayer()
-- Draw a button (text, font, x, y, w, h, [color])
if p:Button("$500", "AmmoM", 65,9, 50, 50) then
if SERVER then
ply:Give("weapon_smg1")
end
end
p:Cursor()
p:Render(posss + offset3, angss, 0.15)
end
I'm doing it how I'm supposed to do and nothing happens but errors and every time its telling me
[ERROR] CG] Chikkenslayer:12: attempt to index upvalue 'tdui' (a nil value)
This is the case in eg. cinema_theatron.
Caused by UI getting rendered more than twice, and the render that would pass UI justPressed test uses reflected coordinates instead of real world coordinates.
Based on arguments.
This requires a decent and quick hashing algorithm for all possible argument types to rendering methods (ie. color, string, number)
DrawX
code in X
(ie check for are we rendering yet inside that function)Something like cl_showfps that shows
Thanks for the update but i think you've just created a new bug. Sometimes the buttons just dont work D: Helep ples
Trying to run this code:
local lposition = Vector(-13846, 570, 12880)
local lang = Angle(0,0,0)
local p
hook.Add("PostDrawTranslucentRenderables", "Paint3D2DUI", function()
p = p or tdui.Create()
p:Rect(-320, 0, 640, 600, Color(255,0,0, 50), Color(255,0,0,255))
p:Text(game.GetMap(), "!Roboto@90", 0, 0)
p:Cursor()
p:Render(lposition, lang, 0.1)
print(lang)
end)
lang constantly gets set between 3 Angles
90.000 90.000 0.000
-0.000 0.000 0.000
-0.000 -90.000 90.000
Doing the local var inside the hook, or putting the angle directly into the Render part works fine (I'm reading from a table however so cannot).
The position however is fine.
Basically you can interact with a button, even if it is trough a prop, wall, double wall, anything. Just aim, and boom. If you can fix that, i would appreciate. Thanks in advance
LocalPlayer()
in ComputeScreenmouse
etc)local posss = self:GetPos()
local angss = self:GetAngles()
local offset3 = angss:Up() + angss:Forward() * 22 + angss:Right() * 1.9;
angss:RotateAroundAxis(self:GetAngles():Up(),180)
angss:RotateAroundAxis(self:GetAngles():Right(),360)
angss:RotateAroundAxis(self:GetAngles():Forward(),360)
cam.Start3D2D(posss,angss,0.15)
local p
hook.Add("PostDrawTranslucentRenderables", "Paint3D2DUI", function(bDrawingSkybox, bDrawingDepth)
-- This is required so that TDUI isn't drawn twice (which would break input)
if bDrawingDepth then return end
-- Create a 3D2D-IMGUI instance and cache it
-- Note: if drawing TDUI inside a ENT:Draw(), you should cache the
-- panel to the entity instance (self) instead of a local variable.
-- That way there will be one panel per entity.
p = p or tdui.Create()
-- Draw a button (text, font, x, y, w, h, [color])
-- Return value is boolean indicating whether left mouse or +use was pressed during this frame
if p:Button("$500", "AmmoM", 60,9.5, 50, 50) then
RunConsoleCommand("say", "hi!")
end
p:Render(posss+offset3 ,angss, 0.15)
end)
cam.End3D2D()
I'm trying to make a button but it doesn't work from when i changed the angles to match entity's model correct placement. If i change the angles to some weird positions it starts working again but only from one side if that makes sense.
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
To quickly create fonts or retrieve cached versions of them. Probably something like
ui:GetFont("Roboto", 180)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.