How to draw a 2D circle on a GameObject?
Asked Answered
C

1

0

For example, consider if someone wanted to draw a pie graph on some terrain. But the graph lays on top of the terrain. In my case, I just want to draw a circle on top of a Cube.

I suppose I could draw a 3D disc if I had to. Any thoughts?

Convexoconvex answered 6/6, 2023 at 2:10 Comment(0)
M
0

You could use a projector placed above the cube or you could manually place a plane with the pie graph texture on it directly above the cube.

However, if all you wanted to do was simply draw a solid circle of one color, you could create a cylinder gameObject, set the Y scale to something like .01, place that cylinder above your cube, set the material's color to whatever color you need, and scale that using Vector3.Scale.

Mccarver answered 6/6, 2023 at 1:43 Comment(5)

The only problem with using a texture is that I want the circle to be able to grow/shrink as the user moves a slider.

Convexoconvex

But I'll try the Projector approach.

Convexoconvex

Hmm... so what if I use the Projector approach but still want a circle to grow/shrink? Is this going to be possible?

Convexoconvex

Yup, all you have to do is set the projector to orthographic, then change the projector's A) height above the cube or B) orthographic size. Here's the script reference for projectors: http://unity3d.com/support/documentation/ScriptReference/Projector.html Also, don't forget to accept and upvote this Answer if it works for you. ;)

Mccarver

Thanks! And don't worry, I won't ;)

Convexoconvex

© 2022 - 2024 — McMap. All rights reserved.