Advanced usage

This page details some advanced usages of the package that require some more configuration.

Contents

Rendering from different threads

This is very similar to rendering from burst jobs. You need to create a custom CommandBuilder on the main Unity thread, use it from the separate thread and then Dispose it on the main thread once you are done.

var draw = DrawingManager.GetBuilder(true);
var thread = new System.Threading.Thread(() => {
// Draw a big grid
using (draw.WithDuration(10)) {
draw.WireGrid(float3.zero, Quaternion.identity, new int2(100, 100), new float2(10, 10), Color.black);
}
});

thread.Start();
thread.Join();
draw.Dispose();

Rendering to RenderTextures

By default the package will never render to cameras that render to render textures. You can enable this using Drawing.DrawingManager.allowRenderToRenderTextures. You may also use the technique described in the next section.

DrawingManager.allowRenderToRenderTextures

Allow rendering to cameras that render to RenderTextures.

Rendering to specific cameras

By default the package will render to all valid cameras. Sometimes you may want to render to only a specific camera.

You can do this by creating a custom command builder and setting the cameraTargets property.

var draw = DrawingManager.GetBuilder(true);

draw.cameraTargets = new Camera[] { myCamera };
// This sphere will only be rendered to myCamera
draw.WireSphere(Vector3.zero, 0.5f, Color.black);
draw.Dispose();

CommandBuilder.cameraTargets

Can be set to render specifically to these cameras.