Proper CUi Documentation?

Sorry if this isn't the correct place to post this, but I've recently been getting into writing plugins and I can't seem to understand the UI system. Like what is anchormin and anchormax? And do the values change based on the positioning of the parent panel? Is there anywhere I can go that gives an in-depth explanation?

 

Thanks!

Go0ePa8S2poB3OZ.jpg Wulf

https://umod.org/community/rust/9103-cuihelper-documentation

I don't know if anyone has written any docs for it yet, but you can take a look at the helper Oxide provides for it or by looking at threads and plugins.

Thing is im able to understand the basis of it im just mainly confused about anchormin/anchormax. Can't find any explanation of what they are whats done with the values

From another thread:

To move elements you can use anchors (relative to screen W/H 0.0 - 1.0) and offsets (pixel count, anchors would still take effect).
Best way to make UI's - set position with anchors (ie. Min: "0.5 0.5" Max: "0.5 0.5") and set size with offsets (ie. Min"-50 -20" Max: "50 20") <-- this will produce rectangle 100x40px in the middle of the screen.

Go0ePa8S2poB3OZ.jpg Wulf

From another thread:

To move elements you can use anchors (relative to screen W/H 0.0 - 1.0) and offsets (pixel count, anchors would still take effect).
Best way to make UI's - set position with anchors (ie. Min: "0.5 0.5" Max: "0.5 0.5") and set size with offsets (ie. Min"-50 -20" Max: "50 20") <-- this will produce rectangle 100x40px in the middle of the screen.

So Offsetmin/max is the size and anchormin/max is the position?

The TL;DR is that anchors should be used to determine which corner or edge (or center) of the screen to snap the elements to (there are at most 9 combinations anyone should use), and the offsets should be used to determine simultaneously (1) the position of the element relative to the anchor point, and (2) the size of the element.

The value of AnchorMin and AnchorMax should be the same. For example, "0.5 0" represents the bottom center of the screen. The values of the offsets will depend on what you want to draw, and will determine (1) the bottom left corner and (2) the top right corner the element rectangle.

What people often get wrong is that they just use anchors. The problem with only using anchors is that the elements will have an inconsistent aspect ratio for different screen aspect ratios. For example, if the element is 16:9 on a 16:9 screen, then changing the screen to 4:3 will also change the element to 4:3. While that may be desirable for some rare cases, it's not usually what people want. The reasons it's not what people want are (1) it can cause images to stretch, and (2) it does not line up with vanilla UI, which many plugins try to draw UI relative to. A great example of this is the vanilla hot bar. Each slot in the hotbar is always a square, regardless of the screen aspect ratio. If you want the same effect, you need to use anchors + offsets as I explained at the beginning.

One exception to the rule of "don't use just offsets" is that you can probably get away with it inside a nested element, if the root parent element is using offsets.

bump, any documentation yet after year?

A community member has put together some documentation which they intend to get merged into Facepunch's Rust.Community repository (the repository that contains the code for client-side CUI).

https://github.com/Kulltero/Rust.Community/tree/Docs

Note: The docs describe the client API contract, not specifically how to use Oxide's implementation, but that should be of little issue as Oxide's implementation is basically 1:1 with the client API. The only exceptions are CuiPanel, CuiLabel and CuiButton which are very lightweight abstractions around the Facepunch primitives. You can easily see how those work by reading the code on GitHub which is pretty self-documenting.

i lookin some documentation about Cui and scroll 

any one can share some information or documentation for that