InteractableTarget
Namespace: FireSoftworks.Interaction
Type: Class · MonoBehaviour
Assembly: FireSofworks.InteractionSystem
Implements: IInteractable
Constraint: [DisallowMultipleComponent]
Default implementation of IInteractable. Aggregates interaction actions from attached IInteractableAction components and from manually assigned InteractableActionSO assets, caches the merged list, and sorts it by Id.
[DisallowMultipleComponent]public class InteractableTarget : MonoBehaviour, IInteractableSetup
- Add
InteractableTargetto any GameObject with a Collider. - (Optional) Assign SO action assets to the SO Actions list in the Inspector.
- Add
InteractableActioncomponents (orInteractableActionSOWrappercomponents) to the same GameObject for component-based actions. - (Optional) Assign a Focused Material for automatic outline/highlight on focus.
Inspector fields
| Field | Type | Description |
|---|---|---|
soActions | List<InteractableActionSO> | ScriptableObject actions assigned manually. Combined with component-based actions. |
focusedMaterial | Material | Applied as an extra material layer when the player focuses on this object. Removed on OnFocusExit(). |
Methods
GetGameObject()
public GameObject GetGameObject()Returns gameObject.
GetAvailableActions(InteractionContext)
public List<IInteractableAction> GetAvailableActions(InteractionContext context)Returns actions for which IsAvailable(context) returns true, sorted by Id ascending. Populates the cache on first call.
GetAllActions()
public List<IInteractableAction> GetAllActions()Returns all actions regardless of availability, sorted by Id ascending. Used by InteractorBase to build the full visible list. Populates the cache on first call.
RefreshActions()
public void RefreshActions()Clears the cached action list, forcing rediscovery on the next GetAllActions() / GetAvailableActions() call. Call this if you add or remove action components at runtime.
OnFocusEnter(InteractionContext)
public void OnFocusEnter(InteractionContext context)If focusedMaterial is assigned, appends it to the object’s Renderer.materials array for the duration of the focus, creating a highlight effect without replacing original materials.
OnFocusExit()
public void OnFocusExit()Restores the original materials array and calls RefreshActions().
Action discovery order
GetComponents<IInteractableAction>()— discovers all attached MonoBehaviour actions.soActionslist — appends all assigned SO assets.- The merged list is sorted by
IInteractableAction.Id(ascending, string comparison).
All three action types (InteractableAction, InteractableActionSO, InteractableActionSOWrapper) are picked up transparently in step 1 or 2.