4 ms·
Actually a circle is very easy to draw using a shader: (4th answer down) https://stackoverflow.com/questions/13708395/how-can-i-draw-a-circle-in-unity3d https:
by bufferoverflow 7y ago
Actually a circle is very easy to draw using a shader:
(4th answer down)
https://stackoverflow.com/questions/13708395/how-can-i-draw-a-circle-in-unity3d https://stackoverflow.com/questions/13708395/how-can-i-draw-...
A pie chart would be harder.
- DonHopkins 7y agoBut drawing that circle (or a pie chart) into a texture (so you don't have to draw each triangle every frame) is a whole can of worms. It might be fine in some cases on a big honking workstation, but reducing the number of draws and triangles becomes quite important when you're doing mobile user interfaces or VR. Also, it would take a hell of a lot of programming to duplicate the canvas api with LineRenderer and dynamic meshes. And then you've rolled yourself a custom C# drawing API, so there aren't any full featured well supported off-the-shelf libraries like d3 or chartjs to drive it. One of the nice things about the way UnityJS integrates JavaScript with a standard web browser in Unity apps is that you can use any of the enormous ecosystem of existing off-the-shelf JavaScript libraries without modification (both visual canvas drawing, and JSON based data wrangling libraries and APIs for services). It's all about leveraging existing JavaScript libraries and web technologies, instead of reinventing half-assed Unity C# versions. Given any JSON based web service or SDK you might want to talk to (google sheets or slack for example), the chances of finding a working well supported JavaScript library that talks to it are a lot higher than finding an equivalent C# library that runs in Unity. (Socket.io is a good example: there exist some for Unity, but they all have problems and limitations, and none of them compare in quality and support to the standard JavaScript socket.io library.)
- pcwalton 7y agoYou've described exactly why I want to integrate Pathfinder into Unity [1]. :) Pathfinder offers a subset of HTML canvas that I would like to expand over the next few weeks and months into the full API. (Ideally it will actually be the HTML canvas implementation for Firefox someday.) There's also the benefit that Pathfinder can transform the canvas in 3D while keeping the content in vector form (i.e. no quality loss), which is important for VR. [1]: https://github.com/pcwalton/pathfinder/issues/147 https://github.com/pcwalton/pathfinder/issues/147
- maeln 7y agoIt's even more simple using a SDF, and making it a pie-chart is almost trivial: https://iquilezles.org/www/articles/distfunctions2d/distfunctions2d.htm https://iquilezles.org/www/articles/distfunctions2d/distfunc...