Handle mouse picking, hover, and selection of objects with an Interaction component, and route Unity pointer/selection events to targets.
| Class | OC.UI.Interactions.SelectionManager |
| Script | Runtime/Interactions/Scripts/SelectionManager.cs |
| Prefab | Child SelectionManager under Interactions.prefab |
| Pattern | MonoBehaviourSingleton<SelectionManager> |
Enable property gates all selection logic. When set to false:
- Hit state is reset
- Current selection is cleared
The Interaction Tool on the AppUI toolbar toggles Enable via UnityEvent (set_Enable). Selection is off by default in the shipped prefab (_enable: 0).
- Uses
Camera.mainandPhysics.RaycastNonAllocwith configurable_layerMask(default: bit 10 / layer "Interactable" depending on project setup). - Maximum distance: 500 units.
- Ignores hits closer than
OC.Utils.TOLERANCE. - Objects tagged
HandlespopulateHandleRaycastHitinstead of the object hit list (transform gizmo takes priority). - Closest hit receives pointer enter; previous closest receives pointer exit.
| Input | Behavior |
|---|---|
| Click performed (down) | Select hit object; Ctrl cycles among multiple hits along the ray |
| Click canceled (up) | Fire pointer click/up on closest hit |
| Empty click | Clear selection |
Selection rules:
- Target must have
InteractionwithInteractionMode.Selection. - Skips interactions in
InteractionState.Disabled. - Toggle: click selected object again to deselect.
- Ctrl: additive selection (no clear before add).
OnSelectionChanged—List<Interaction>after any selection change; used byPanelManager,EditorToolsPanel,RuntimeTransformHandle.OnDestroy— when a selected interaction’s payload is destroyed via pool.
Cancel input action (when no UI focus conflict):
- Deselects last selected interaction if any
- Otherwise closes last floating panel
- Otherwise toggles exit popup
See AppUI.cs.
- Include Interactions prefab (contains SelectionManager).
- Set layer mask to match interactable collider layers.
- Assign click and pointer actions from OC Input Actions.
- Enable Interaction Tool at runtime for operators.