UI Drawing - Guad/NativeUI GitHub Wiki

NativeUI uses it's own coordinate system that differs from the default ScriptHookDotNet one. This way the UI always looks good on any resolution.

NativeUI introduces UIResRectangle, UIResText and Sprite classes. They are as easy to use as their ScriptHookDotNet counterparts.

Coordinate System

NativeUI uses 1080 pixels as a base height, and then calculates the width based on the user's current aspect ratio (Screen width/Screen height). This way the aspect ratio of your menus is always mantained.

UIResText

UIResText expands on UIText by adding a TextAlignment property and WordWrap property. Using the TextAlignment you can align your text to the left, center or right. WordWrap property will wrap your text after X pixels.

Sprite

Using the Sprite object is very easy. To create a gradient background, you can do this:

var background = new Sprite("commonmenu", "bgd_gradient", new Point(100, 20), new Size(200, 500)); You can then alter it's Heading, Color, Size, Position, TextureDict and TextureName.

Custom Textures

The Sprite class has a few methods that enable you to draw custom textures. The main one is DrawTexture(string path, Point position, Size size). You can also embed your textures into your DLL and then write them to hard disk using the WriteFileFromResources(Assembly yourAssembly, string fullResourceName, string savePath); It's as easy as this:

Sprite.DrawTexture(WriteFileFromResources(Assembly.GetExecutingAssembly(), "MyModName.picture.png"));
// Calling WriteFileFromResources without a savepath will save the file to the Temp folder.

Note that the fullResourceName should be prepended with your solution name. The end result should be something like MySolutionName.Picture.png