DIY GUI
Defining a GUIScript
key can be compared to any "InputKey" value, down corresponds to whether the key is pressed or released.
Creating and Destroying a GUI
GetGUIManager():CreateGUIScriptSingle("GUIDIY")
GetGUIManager():DestroyGUIScriptSingle("GUIDIY")
Create an instance of your GUI. Create and destroy as many as you want!
local script = GetGUIManager():CreateGUIScript("GUIDIY")
GetGUIManager():DestroyGUIScript(script)
text = GUIManager:CreateTextItem()
GUI.DestroyItem(item)
All GUI items must be destroyed using DestroyItem or they will "leak". If you lose your reference to the GUI item before destroying it you will end up with phantom GUI items on the screen. These can only be removed by rejoining a server. DestroyItem will also destroy any children of the item you're destroying.
Position, Size, and Scale
Anchor
Color and Texture
Use "unpack({x,w,w,h})" to pass in a single table, or pass in each parameter seperately.
Text
Text works similar to other GUI elements, but there are some differences
Lines
Lines can only be 1 px thick right now.
Most of the regular GUI functions will work: Anchor, Position, Color, Visible, Layer, Parent, etc
Line Specific functions:
lineItem = GUIManager:CreateLinesItem()
Create a new Lines Graphic Item
AddLine(VectorPosition1, VectorPosition2, Color)
Draws a line from position1 to position2 with color
ClearLines()
Clears all the lines from a Lines Item
Other Commands
AddChild(GUIItem)
Adds a child to the gui item. A child will use its parent's position as its origin instead of (0,0). Children/Parents are covered elsewhere in the guide
SetRotation(radian float)
Set rotation, //TODO I think this rotates around the top left corner.
SetLayer(int)
Sets the layer of the item. 0 is the lowest layer. Check GUIManager.lua to see some layer constants.
SetIsVisible(boolean)
Sets the item and all children invisible
GetScreenPosition(Client.GetScreenWidth(), Client.GetScreenHeight())
Gets the absolute screen position of the item. If the item is a child, GetPosition() will return its relative position, not its absolute position.
SetInheritsParentAlpha(true)
Item will inherit its parent's alpha.
Examples
Drawing Overhead camer projection lines from GUIMinimap.lua
This guide was created by its original author on the Steam Community. Are you the author and want it removed? Request removal.