Hi guys,
is there an easy way to render a spline at runtime? even if its a temporary fix?
ta
Hi guys,
is there an easy way to render a spline at runtime? even if its a temporary fix?
ta
There is nothing built-in except for Handles.DrawBezier which only works in scene view.
One way is to compute and sample your spline and draw it as a series of short lines. GL class can be used for simple lines, and LineRenderer if you need something more fancy.
The other is to look up a plugin for your need here
I’ve posted the cubic bezier calculation a couple of times:
In this Utah teapot example(WebGL) i made i’ve included parts of my “drawing” class. It also has a “cubic bezier” method (BezierLineGL). Keep in mind to setup a proper projection / viewport for the GL class. Also keep in mind that things drawn with the GL class are drawn immediately. So watch out where you draw your lines. Inside Update won’t work since Update is called even before the camera clears the screen. Either use OnRenderObject, OnPostRender on a camera, during the repaint event in OnGUI or in a coroutine after WaitForEndOfFrame.
The project is zipped on the github page