- Home /
How do I draw a circle around a selected gameObject?
I just coded the ability to select a unit (gameObject) by clicking on it, now i`d like to give a visual indicator that the unit is selected.
What would be a good solution for displaying a 2d circle in 3d space around the base of a game object.
The one thing I can think off is having instantiating a cylinder gameObject at the base of the selected gameObject (as its child), setting its y to 0 so its flat, and giving it appropriate scale transforms so it is just as big (or a bit bigger) than the selectedGameObject. Then I can give the cylinder an appropriate material that would display only the outline of the cylinder and leave the insides transparent. If this is a good approach then how would I create such a material for the cylinder?
Other option I was told on IRC is to have two cylinders, one on top of each other, the smaller one on top is invisible and using some depth culling mumbo jumbo I can make the larger cylinders insides invisible. I still need to investigate this option.
Is there a more elegant solution to this? some way of just rendering a circle in 3d space? This will need to be applied to multiple units on screen once I code in multiple unit selection so performance is a consideration (as there could be 100's of selected units on screen at once).
Answer by Peter Alexander · Dec 23, 2009 at 12:22 PM
The simplest (and most common) solution to this problem is to simply have a texture of a circle applied to a quad that you place below the object.
Answer by MikeB · Dec 23, 2009 at 06:00 PM
I agree with Peter Alexander; additionally, if you are going to be drawing 100's of selection indicators, you may not want to Instantiate (and destroy) the circles everytime the selection changes. The textured quad could be a part of the model, and the script which tells the model that it is selected just enables (or disables) the mesh renderer for that quad.
Tho' honestly I don't know that that makes a difference, performance wise - so as always, try it, profile, and see what happens.
Answer by freeclup · May 31, 2013 at 07:28 AM
load object and set it under player i attached simple arrow.fbx, this object created in autocad and surfaced with 3ds
Your answer
Follow this Question
Related Questions
Material doesn't have a color property '_Color' 4 Answers
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Share material on Instantiate() 1 Answer
Select colour then change texture 0 Answers
How to make an object to be drawn over all other objects through script in realtime? 1 Answer