Cursor Interactor
NAMESPACEMyDreamGameStudio.InteractAnything
MENU PATHInteraction System > Interactors > Cursor Interactor
COMPATIBILITYUnity 6.0+
DOC VERSION
Interacts with whatever the cursor is actively pointing at. This interactor casts a ray from the camera through the current mouse or pointer position each frame to detect focus targets. It is engineered specifically for top-down, RTS, simulation, or point-and-click interaction models.
Editor Interface
Configuration
Target Resolution Pipeline
When the CursorInteractor fires its raycast against the world, it uses a specific fallback hierarchy to resolve targets. This allows you to build complex prefabs without duplicating scripts.
- Direct Hit: It first checks if the hit
Colliderhas anInteractablecomponent directly attached. - Parent Fallback: If not found, it checks
GetComponentInParent<Interactable>(). This is extremely useful for setup; you can place a large trigger collider on a drawer handle, but keep the actualInteractablescript on the root Drawer object. - Spatial Data Override: If no valid interactable is found, the system still caches the exact point on the ray boundary. This ensures that if the player is currently operating a Drag or Push/Pull mechanic, continuous spatial data is still fed to the active component even if the cursor temporarily slips off the mesh.
Runtime API
The interactor exposes public configuration methods so external modules (like the ExaminePanel or custom input switchers) can hot-swap targets and cameras without requiring duplicate interactor components in your scene.
// Overrides the camera driving the screen-point raycast
public void SetSourceCamera(Camera camera);
// Restricts or expands which physics layers can be targeted at runtime
public void SetInteractableLayers(LayerMask layers);