Skip to content

Commit

Permalink
feat(Avatar): allow custom model to be provided
Browse files Browse the repository at this point in the history
The Avatar Hand Controller script can now have a custom Model
Transform injected into the inspector component in case the
model is not a child called `Model`.
  • Loading branch information
thestonefox committed Oct 26, 2017
1 parent c48a9cd commit 53850d0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions Assets/VRTK/Documentation/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -1109,6 +1109,7 @@ Provides a custom controller hand model with psuedo finger functionality.
* **Touch Overrides:** Finger axis overrides on an Interact Touch event.
* **Grab Overrides:** Finger axis overrides on an Interact Grab event.
* **Use Overrides:** Finger axis overrides on an Interact Use event.
* **Hand Model:** The Transform that contains the avatar hand model. If this is left blank then a child GameObject named `Model` will be searched for to use as the Transform.
* **Controller Events:** The controller to listen for the events on. If this is left blank as it will be auto populated by finding the Controller Events script on the parent GameObject.
* **Interact Near Touch:** An optional Interact NearTouch to listen for near touch events on. If this is left blank as it will attempt to be auto populated by finding the Interact NearTouch script on the parent GameObject.
* **Interact Touch:** An optional Interact Touch to listen for touch events on. If this is left blank as it will attempt to be auto populated by finding the Interact Touch script on the parent GameObject.
Expand Down
4 changes: 3 additions & 1 deletion Assets/VRTK/Prefabs/AvatarHands/VRTK_AvatarHandController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ public class VRTK_AvatarHandController : MonoBehaviour

[Header("Custom Settings")]

[Tooltip("The Transform that contains the avatar hand model. If this is left blank then a child GameObject named `Model` will be searched for to use as the Transform.")]
public Transform handModel;
[Tooltip("The controller to listen for the events on. If this is left blank as it will be auto populated by finding the Controller Events script on the parent GameObject.")]
public VRTK_ControllerEvents controllerEvents;
[Tooltip("An optional Interact NearTouch to listen for near touch events on. If this is left blank as it will attempt to be auto populated by finding the Interact NearTouch script on the parent GameObject.")]
Expand Down Expand Up @@ -703,7 +705,7 @@ protected virtual void DetectController()

protected virtual void MirrorHand()
{
Transform modelTransform = transform.Find("Model");
Transform modelTransform = (handModel != null ? handModel : transform.Find("Model"));
if (modelTransform != null)
{
modelTransform.localScale = new Vector3(modelTransform.localScale.x * -1f, modelTransform.localScale.y, modelTransform.localScale.z);
Expand Down

0 comments on commit 53850d0

Please sign in to comment.