Back

Custom Handles creator a Unity plugin

Meta data

General

NameAdvanced Handles
Typesingle person project
Completed2016

Contribution

Programming100%
Concept100%

Technical

EngineUnity 5.5
LanguageC#

About Advanced handles

In Unity there is a class named Handles. This class enables you to draw Gizmos like arrows or lines in the scene view. This can be useful for debugging or for custom plugins like placing tools or waypoint systems. Advanced handles are used like build in handles, but now you can create your own handles with custom meshes like a flag or arrow. This handle can have different interactions like MouseClick, MouseOver, Slide or Rotate. A handle can also be a line with a head, body, and tail mesh. The biggest benefit is that a handle is by default drawn like any other object in the scene. It is a part of the world. So, when a part of the line is behind an object, you won't see it. This makes it easy to see exactly where the line is.

Handle generation

In the creator window you can create handles. When you hit generate, the plugin generates a few C# files inside the project, so you can access the handles from your own scripts. The handles are split into 4 files: AdvancedHandles where everything comes together, InteratableHandles where the codes for the different interactions are, MeshTemplates where the data of the meshes are stored and AdvancedHandlesTools with methods used by all other classes. You can move those 4 files to different projects or add them to your plugin without needing the Advanced Handles Creator.

Technic

All the logic of the handles come together in the AdvancedHandles class. Here you find all methods for each handle. When you call a handle method, it draws the handle in the scene and calls different methods if needed, like all interactions. The interactions are inside the class InteractableHandles so we don't have to copy them for each handle.

The meshes are stored the MeshTemplates class. The data is stored in arrays. The AdvancedHandles class can get the meshes from this class. The first time they are created from those arrays in a private static variable. After that, they give this static private variable when a class ask for it for performance.