Unit Selection
  • Welcome
    • πŸ‘‹Hello
    • πŸ—ΊοΈRoadmap
    • ⛑️Support & Community
    • πŸŽ“Changelog
  • Getting started
    • πŸ”ŒImport package
    • πŸ› οΈAdd selection to scene
    • 🦲Add selection to units
    • β›³Add visuals to units
  • How it works
    • 🎯Active Selections
    • 🫡Unit Selector
    • πŸ”’Quick Access Selector
    • ⬛Selection Area
      • πŸ”²2D Rectangle
      • 🧊3D Cube
    • πŸ’ Selectable Unit
      • πŸ“Selection Bounds
      • β­•Selection Indicator
    • Selectable Group Unit
    • ⌨️Input Controls
    • πŸ‘·β€β™€οΈUnit Management
Powered by GitBook
On this page
  1. Getting started

Add selection to scene

Step-by-step guide to add selection system to your scene

PreviousImport packageNextAdd selection to units

Last updated 18 days ago

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:

  1. You can start by creating an empty Game Object and attach UnitSelector component 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.main will 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)

  2. 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.

  3. 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 UnitSelector or by implementing your own AInputControl

    • Legacy Input: uses built-in Unity input system

    • New InputSystem: utilises Unity latest and flexible input system (Package manager dependency)

  4. Finally you can update any UI or notify your own components of selection events in the Events tab.

  5. 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.

πŸ› οΈ
Page cover image