Garry's Mod Wiki

Revision Difference

VGUI_Creating_Custom_Elements#560406

<cat>Dev.UI</cat>⤶ <title>VGUI Creating Custom Elements</title>⤶ ⤶ # Why Create Custom VGUI Elements?⤶ Creating custom VGUI elements helps with many things, the biggest being code readability and maintainability. These new elements don't always have to be some brand new element from the ground up, in fact many custom elements are just derivatives from the games base panels with customizations that fit that project better.⤶ ⤶ Think of something like a <page>DButton</page> the default styling may not suit the look and feel of your project, so instead of having to restyle every <page>DButton</page> you create, you can create a new custom VGUI element that is derived from the standard <page>DButton</page>. Then apply your styling to that the new element once. This means that each time you create this new custom element you wont need to reapply the same styling, you'll only need to add what makes that button unique.⤶ ⤶ Now you _could_ create panels in the same file you want to use them with <page>vgui.CreateFromTable</page> however using this method to create panels usually leads to a very long file that becomes hard to read and maintain once your no longer activity working on it. Therefor while acceptable under specific circumstances this shouldn't be the main way of creating your custom elements. ⤶ ⤶ ⤶ ⤶ ⤶ ⤶ ⤶ ⤶ #Uploading Images⤶ ⤶ I can drag and drop images and videos here to upload them.⤶ ⤶ #Links⤶ ⤶ I can link to [external pages](http://www.google.com) and <page>Internal Pages</page>