🛠️Add selection to scene
Step-by-step guide to add selection system to your scene
Here you can follow few short steps to add selection to your scene. You can choose from predefined selection areas or implemented your own.

Steps to set up:
You can start by creating an empty Game Object and attach
UnitSelectorcomponent to it or by dragging the SelectionSystem prefab into your scene, which is partially already configured for use. See Main tab and set up the following:Once Selection is in the scene, set the camera to your player's camera (
Camera.mainwill be used if it's not set)Check out configuration options and adjust them for your project respectively
Set maximal selection number, if required.
Enable or disable quick access for units (saving and loading selection)
Next click on Selection Area tab and choose from one of the two provided selection area's or reference your custom one. For more details about them and their detection types see here Selection Area.
1st option: Selection Screen Rectangle for 2D screen space selection area.
2nd option: Selection World Cube for 3D world space selection area.
Here you have to set the Ground Layer Mask because the world selection needs ground position to start somewhere.
Now you can set up player interactions with the input on Input tab. Here you have support for:
None: requires manual management of selection active states, either directly on
UnitSelectoror by implementing your ownAInputControlLegacy Input: uses built-in Unity input system
New InputSystem: utilises Unity latest and flexible input system (Package manager dependency)
Finally you can update any UI or notify your own components of selection events in the Events tab.
Save Scene.
In case your camera is spawned later or loaded with a different scene, you can always use set it up later once you have the reference to it. Like this:
// Set camera in code at any time
FindObjectOfType<UnitSelector>().SetCamera(Camera.main);Ok, You are now done with scene set up.
Last updated
