π¦²Add selection to units
Quick guide to set up your units for selection.
Last updated
Quick guide to set up your units for selection.
Last updated
Video: You can also see the quick set up video here.
This package supports out of the box selection support for units. Follow the steps below to set up your game object for selection.
Steps to set up:
Add SelectableUnit component on any of your game objects (ideally prefabs). This adds core functionality and supports Click and Hover for objects, but not drag selection and few others like managed filtering. Groups: For selecting groups or squads of units, use SelectableGroupUnit component for each single unit itself and then on your group controller add SelectableGroup component.
If you wish to use Drag selection feature and all others, you should also click the Enable drag selection button on this component or manually add ManageUnitObject component.
Make sure the game object with component has a Collider of any type.
This is important for hover and mouse click, as well as mouse drag with collision detection types. Without colliders collision detection or raycasts cannot be used.
Set Layer of the game object to selectable layer you have added or used for selection system, described here: Add selection to scene.
Save unit prefab.
To find out more about specific selectable component check out Selectable Unit and Selectable Group Unit pages.
And that is it! With collider, layer and SelectableUnit component you should be able to select game objects. Next step, add visuals to see selection in action.