- Home /
Render spline?
Hi guys,
is there an easy way to render a spline at runtime? even if its a temporary fix?
ta
Answer by ttRevan · Nov 01, 2015 at 05:56 AM
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
Thanks dude for your feedback, ill look into those! I suspected nothing was built in for it :/
take care :)
Answer by Bunny83 · Nov 01, 2015 at 10:38 AM
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
Forgot about CurveEditor, it provide sampling out of the box :) +1
Hey Bunny, your link with the example doesn't work. Do you still have it?
Yes. I moved some of my examples to github since dropbox does no longer display html content. I also made a WebGL version some time ago. I'll fix the link in my answer.
Your answer
Follow this Question
Related Questions
Curvy package...How can i get all points 2 Answers
Rendering with the CPU in Unity 0 Answers
GrabPass and Transparent geometry 0 Answers
Why am I getting shadow strange artifacts? 1 Answer
Rendering problem? 0 Answers