Choose a tutorial:
The full potential and flexibility of Draw XXL is leveraged when drawing from code. Draw XXL offers a static drawing library where you can call drawing functions from anywhere in your code without initializing objects - as known from using Unitys Debug.DrawLine().
All you have to do to get started is declaring the usage of the Draw XXL namespace on top of your scripts, like so:
Now there is the question how to find out which draw functions Draw XXL offers and what their names and signatures are. This is where the API documentation comes into play.
The API documentation is your starting point on the journey of learning the numerous available options. To make navigation easier every category and every drawn object is visualized with an image. So you can literally browse the API documentation "by image" instead of the normal approach of "by class and function names".
Lets go through an example:
On the API overview page you see different preview images that represent different shape categories, like so:
Now say you want to draw a vector to visualize the forward direction of a GameObject. On the API overview page you see that the category "Draw Basics" has a vector. After clicking on the Draw Basics category another page with many images opens. The images represent all shapes that you can draw inside the Draw Bascis category.
Again you can scroll up and down to see what drawing options are available. While scrolling you see the wanted vector:
Let's choose "VectorFrom". After clicking on VectorFrom the actual description of the vector (function name and signature) opens:
We can see from the function description the name of the vector draw function and the expected parameters. There are two mandatory parameters: "vectorStartPos" and "vector". These mandatory parameters are colored green in the API documentation. With that information we can craft our first drawing call to the Draw XXL library, like so:
In the Unity Editor something like this should appear:
We already saw that green parameters from the function signature are mandatory. But what about the yellow parameters? Yellow parameters are optional, but have to be supplied in the correct order. They are used to further customize the drawn shape. Draw XXL makes heavy use of such optional parameters. In many cases they can just be ignored (since they are only optional), but in other cases it is good to have them and be able to tweak a drawn shape.
Let's use some optional parameters to tweak our vector.
The first optional parameter is "color". We can extend our code line like this:
This should color our vector like so:
In busy environments drawn shapes are sometimes not good recognizable. An easy way to fix this is to raise the line width of the vector. "lineWidth" is the next optional parameter. Our code is then like so:
And in the Editor it looks like this:
Finally we can add a text tag to the vector. "text" is the next parameter.
A vector with text tag: