- Home /
Setting transform parents to Vectrosity canvases.
I started using vectrosity recently and I'm using it to draw a strategic circle around units and structures. I realized that calling myVectorLine.Draw() every frame for objects that are moving so that the circle updates with their position is a MASSIVE CPU hog. I would prefer to have the canvas's transform parent set to the unit itself, so that I only have to draw the line once, and it just moves with the unit.
I've done this with other things such as health and progress bars by using a world-space canvas (Draw3D() with vectrosity). However I am not sure how to go about doing this with vectrosity since after myVectorLine.Draw3D() is called it automagically creates the canvas as a top-level object. I can set the rectTransform and transform of the line (per documentation) to the unit, however the canvas is still a top-level object in the hierarchy and requires Draw3D() to be called every frame as the unit moves through the scene.
Anyone with vectrosity experience want to chime in on this one?
Answer by imbible · Nov 23, 2017 at 05:46 PM
To specify a canvas, you could use VectorLine.SetCanvas (myCanvas); But Vectrosity does not seem to support a world-space canvas.
Excerpted from the official doc - Note that the “myCanvas” variable can either refer to the actual Canvas component, or to the GameObject that the Canvas is attached to. The canvas rendering mode must be either Screen Space Overlay or Screen Space Camera, since a canvas using World Space may produce incorrect results.