Skip to content

Put Back Socket Interactor

eisclimber edited this page Apr 20, 2024 · 3 revisions

Put Back Socket Interactor

class in ExPresSXR.Interaction / Extends class in ExPresSXR.Interaction.HighlightableSocketInteractor
GameObject instantiable via ExPresS XR/Put Back Socket Interactor

Description

An Expansion of the HighlightableSocketInteractor to restrict access to a single GameObject an instance of the putBackPrefab. After a certain amount of time outside the interactor and not being held or selected elsewhere, the object will be snap back to this socket.

The putBackPrefab will be automatically be instanced. If it does not have a XRGrabInteractable-Component and allowNonInteractables is true it will be instanced at the attach point of the socket but won't be able to be interacted with. If the component is missing and the non-interactables are disallowed, the putBackPrefab will be set to null.

If the socket does not hold an object, it will be disabled.

The socket and putBackPrefab can be controlled by an Exhibition Display or any other component by setting externallyControlled to true. This will lock "PutBack" section of the sockets editor, as it is controlled elsewhere.

Members

Public Properties

  • GameObject putBackPrefab: The prefab that is displayed at the socket. Will automatically create an instance of the prefab and update the references.
    Will reject prefabs without a XRBaseInteractable-Component and allowNonInteractables being disabled.
  • GameObject putBackInstance: (Readonly) The current instance of the putBackPrefab. Can not be changed via the editor.
  • XRBaseInteractable putBackInstance: (Readonly) The current interactable of the putBackPrefab. Can not be changed via the editor. May be null if the putBackPrefab has no XRBaseInteractable-Component and allowNonInteractables is true.
  • bool allowNonInteractables: If enabled GameObjects without an XRGrabInteractable-Component will be allowed to be set as putBackPrefab. Otherwise those will be cleared.
  • float putBackTime: The duration in seconds how long the put back object can be unselected outside the socket until being snapped back to the socket. If less or equal to 0, the object will snap back instantaneous. Default: 1.0f
  • bool externallyControlled: Hidden in the editor! Used to disable certain fields in the editor when controlled by an Exhibition Display.

Public Methods

  • void UpdatePutBackObject(): Updates the putBackPrefab by destroying and creating instances, adding/removing listeners and de-/selecting the interactable.
    Will be automatically called when setting putBackPrefab.
  • bool ArePutBackReferencesValid(): Checks if all references derived from the putBackPrefab are valid.
  • bool ValidatePutBackPrefab(): Checks if the putBackPrefab is valid with respect to the current configuration.

Inherited Members

Protected Methods

  • void Awake(): Deactivates the socket if no putBackObjectInstance could be created and sets up the inherited socket classes. Can be overwritten, but base.Awake() should be called to ensure correct behavior.
  • void OnEnable(): Resets the putBackObject when rebuilding to prevent errors. Can be overwritten, but base.OnEnable() should be called to ensure correct behavior.
  • bool CanHover(IXRHoverInteractable interactable): Determines if a XRGrabInteractable can hover, e.g. is considered a valid target. Can be overwritten, but base.CanHover(interactable) should be called to ensure correct behavior.
  • bool CanSelect(IXRSelectInteractable interactable): Determines if a XRGrabInteractable can be selected, e.g. is considered a valid target. Can be overwritten, but base.CanSelect(interactable) should be called to ensure correct behavior.

ExPresS XR Wiki

Tutorial Pages

Code Documentation

Clone this wiki locally