# Unity gizmos vs. referenced game objects

I'm designing a Unity script that I intend to be highly reusable and as easy as possible to setup within the editor. To this end, a number of properties of this script really need some kind of visual representation on screen.

It is an unresolved question to me whether the design of the script should require references to placeholder game objects, OR just Vector3's and float's that have associated gizmos drawn for them.

Normally a gizmo would be a natural choice, except that Unity gizmos are not directly manipulable (as far as I can tell). Because of this shortcoming I'm having to consider whether depending on references to placeholder game objects is a more designer-friendly approach ultimately, in spite of the extra setup required, and that it might be counter-intuitive when the placeholder game objects disappear at run-time (which my script would do).

Is there a community standard or preference here in this case? Can a Unity-experienced game programmer / designer speak to which approach they feel is more intuitive or more convenient to setup, when using a 3rd party script? Or is this just splitting hairs as long as I ship an example prefab with my script?

• What's the intent of the gizmos-or-temporary-objects? Are they to show something in the world or are they placeholders in that your users will reference their implemented objects in place of the temp objects? Or what? – chaosTechnician Nov 7 '12 at 4:26
• @chaosTechnician They are to represent/manipulate design-time properties of the script in a visual way, rather than purely numerical way. The goal is to make the script "easy to setup visually" for the artist or gameplay programmer. – DuckMaestro Nov 24 '12 at 6:42
• You mean like this? docs.unity3d.com/Documentation/Components/… – chaosTechnician Nov 25 '12 at 16:02
• @chaosTechnician More along the lines of in-scene handles/dodads/gizmos. Something they can manipulate and see in 3space. – DuckMaestro Nov 25 '12 at 22:52

You can do things like use the MonoBehaviour.OnDrawGizmos function (link) in your scripts to add extra visual representation in the scene editor of various object properties. It automagically updates gizmos in real time based on changes you make to the object's properties in the inspector. It's also handy to use since the visual effects are not included in a build of the game so you don't have to worry about cleaning up superfluous objects by hand before build-time or by ad hoc script at run-time.
For example, in a racing game I worked on a while ago, I used spheres (with Gizmos.DrawWireSphere) and lines (with Gizmos.DrawLine) to draw the size of and connections between AI trucks' navigation points. It made it much easier to lay out and connect the waypoints and ensure they were properly sized to get the effect we wanted. I also drew lines from the AI trucks to their destinations to make sure they were behaving properly during the game.