I’m creating a Derma Menu, and sometimes I make mistakes, some parts of panel’s childs such as ListBoxes or labels (Any parts of it) Get’s stuck on top right of screen (If errors happen), How can I remove those unwanted panels without rejoining/restarting the game? They also seems to be lagging my FPS.
Not possible unless you cache all the panels you create and add a command to remove them all.
You could remove all panels by getting all of the children of the main panel onto which all others are attached
GetWorldPanel - http://wiki.garrysmod.com/page/vgui/GetWorldPanel
then GetChildren - http://wiki.garrysmod.com/page/Panel/GetChildren
then remove all of them.
Logically it should work
This will remove ALL panels though, like the spawnmenu, contextmenu in sandbox.
I made a script for this: https://dl.dropboxusercontent.com/u/26074909/tutoring/_utilities/concommand_clearvgui.lua
Put it in SERVER/garrysmod/addons/acecool/lua/autorun/client/concommand_clearvgui.lua
type clearvgui in console to remove all vgui elements. Ensure the game-mode is written properly… If the panel doesn’t exist, create it should be the check called when opening the panel. If that check is not added before the vgui opens ( such as on game-modes that create the vgui element once and access many times ) then you’ll get errors. Don’t create once / use many, simply create if it doesn’t exist which will allow you to use many and recreate if an issue arises.
bind i "lua_run_cl vgui.GetHoveredPanel():Remove()