Drawing in a game

Want to draw things in your game too? This is supported out of the box with the ALINE package. You get the same high performance and almpost the same ease of use as in the editor.

To draw inside of a game you need to create a CommandBuilder instance configured to draw even when running in a standalone game.

// Create a new CommandBuilder configured to draw in the game
using(var draw = RetainedGizmosWrapper.instance.gizmos.GetBuilder(true)) {
// Use the exact same API as the global Draw class
draw.WireBox(Vector3.zero, Vector3.one);
}

Note

It is recommended that you use the same CommandBuilder instance for most of your drawing instead of creating a new one for every little thing. This is because every CommandBuilder is rendered as a separate mesh (or meshes), so creating too many could have some impact on performance and memory usage. Creating a few for different systems in your game is not an issue however.