x


How to draw a 2D circle on a GameObject?

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?

more ▼

asked Feb 03, 2011 at 06:57 PM

jacksmash2012 gravatar image

jacksmash2012
557 120 94 107

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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.

more ▼

answered Feb 03, 2011 at 07:07 PM

e.bonneville gravatar image

e.bonneville
6.3k 253 226 283

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.

Feb 03, 2011 at 07:11 PM jacksmash2012

But I'll try the Projector approach.

Feb 03, 2011 at 07:12 PM jacksmash2012

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

Feb 03, 2011 at 07:16 PM jacksmash2012

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. ;)

Feb 03, 2011 at 07:26 PM e.bonneville

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

Feb 03, 2011 at 07:27 PM jacksmash2012
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x118

asked: Feb 03, 2011 at 06:57 PM

Seen: 13446 times

Last Updated: Mar 23, 2013 at 07:46 AM