Skip to content

Commit

Permalink
feat(SnapDropZone): use interaction events for snapping
Browse files Browse the repository at this point in the history
The SnapDropZone has been refactored to now utilise the
interactable object over a simple GameObject. This also
enables the ability to listen for the ungrab event on the
interactable object and then determine the snap on that event
rather than constantly polling in the OnTriggerStay method for
the snap event.

This also means that the default snapped object has been deprecated
and an interactable object is provided as the default.

Only interactable objects can be snapped so this makes more sense.
  • Loading branch information
thestonefox committed Sep 5, 2017
1 parent b0305b0 commit d02fcbd
Show file tree
Hide file tree
Showing 2 changed files with 246 additions and 119 deletions.
37 changes: 35 additions & 2 deletions Assets/VRTK/Documentation/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ Provides a predefined zone where a valid interactable object can be dropped and
* **Highlight Always Active:** The highlight object will always be displayed when the snap drop zone is available even if a valid item isn't being hovered over.
* **Valid Object List Policy:** A specified VRTK_PolicyList to use to determine which interactable objects will be snapped to the snap drop zone on release.
* **Display Drop Zone In Editor:** If this is checked then the drop zone highlight section will be displayed in the scene editor window.
* **Default Snapped Object:** The game object to snap into the dropzone when the drop zone is enabled. The game object must be valid in any given policy list to snap.
* **Default Snapped Interactable Object:** The Interactable Object to snap into the dropzone when the drop zone is enabled. The Interactable Object must be valid in any given policy list to snap.

### Class Variables

Expand Down Expand Up @@ -441,7 +441,7 @@ The InitaliseHighlightObject method sets up the highlight object based on the gi
* Returns
* _none_

the ForceSnap method attempts to automatically attach a valid game object to the snap drop zone.
the ForceSnap method attempts to automatically attach a valid GameObject to the snap drop zone.

#### ForceUnsnap/0

Expand Down Expand Up @@ -476,6 +476,17 @@ The ValidSnappableObjectIsHovering method determines if any valid objects are cu

The IsObjectHovering method determines if the given GameObject is currently howvering (but not snapped) in the snap drop zone area.

#### IsInteractableObjectHovering/1

> `public virtual bool IsInteractableObjectHovering(VRTK_InteractableObject checkObject)`

* Parameters
* `VRTK_InteractableObject checkObject` - The Interactable Object script to check to see if it's hovering in the snap drop zone area.
* Returns
* `bool` - Returns true if the given Interactable Object script is hovering (but not snapped) in the snap drop zone area.

The IsInteractableObjectHovering method determines if the given Interactable Object script is currently howvering (but not snapped) in the snap drop zone area.

#### GetHoveringObjects/0

> `public virtual List<GameObject> GetHoveringObjects()`
Expand All @@ -487,6 +498,17 @@ The IsObjectHovering method determines if the given GameObject is currently howv

The GetHoveringObjects method returns a List of valid GameObjects that are currently hovering (but not snapped) in the snap drop zone area.

#### GetHoveringInteractableObjects/0

> `public virtual List<VRTK_InteractableObject> GetHoveringInteractableObjects()`

* Parameters
* _none_
* Returns
* `List<VRTK_InteractableObject>` - The List of valid Interactable Object scripts that are hovering (but not snapped) in the snap drop zone area.

The GetHoveringInteractableObjects method returns a List of valid Interactable Object scripts that are currently hovering (but not snapped) in the snap drop zone area.

#### GetCurrentSnappedObject/0

> `public virtual GameObject GetCurrentSnappedObject()`
Expand All @@ -498,6 +520,17 @@ The GetHoveringObjects method returns a List of valid GameObjects that are curre

The GetCurrentSnappedObejct method returns the GameObject that is currently snapped in the snap drop zone area.

#### GetCurrentSnappedInteractableObject/0

> `public virtual VRTK_InteractableObject GetCurrentSnappedInteractableObject()`

* Parameters
* _none_
* Returns
* `VRTK_InteractableObject` - The Interactable Object script that is currently snapped in the snap drop zone area.

The GetCurrentSnappedInteractableObject method returns the Interactable Object script that is currently snapped in the snap drop zone area.

### Example

`VRTK/Examples/041_Controller_ObjectSnappingToDropZones` uses the `VRTK_SnapDropZone` prefab to set up pre-determined snap zones for a range of objects and demonstrates how only objects of certain types can be snapped into certain areas.
Expand Down
Loading

0 comments on commit d02fcbd

Please sign in to comment.