Skip to content

Commit

Permalink
Merge pull request #854 from thestonefox/fix/warning-when-using-scrip…
Browse files Browse the repository at this point in the history
…ts-wrong

fix(Interaction): set error if helper script not on interactable object - fixes #848
  • Loading branch information
thestonefox committed Jan 20, 2017
2 parents 6cc5674 + 89c7de9 commit bfddccc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
Expand Up @@ -4,7 +4,7 @@ namespace VRTK
using UnityEngine;

/// <summary>
/// The Interact Controller Appearance script is used to determine whether the controller model should be visible or hidden on touch, grab or use.
/// The Interact Controller Appearance script is attached on the same GameObject as an Interactable Object script and is used to determine whether the controller model should be visible or hidden on touch, grab or use.
/// </summary>
/// <example>
/// `VRTK/Examples/008_Controller_UsingAGrabbedObject` shows that the controller can be hidden when touching, grabbing and using an object.
Expand Down Expand Up @@ -92,6 +92,14 @@ public void ToggleControllerOnUse(bool showController, VRTK_ControllerActions co
}
}

protected virtual void OnEnable()
{
if (!GetComponent<VRTK_InteractableObject>())
{
Debug.LogError("The `VRTK_InteractControllerAppearance` script is required to be attached to a GameObject that has the `VRTK_InteractableObject` script also attached to it.");
}
}

private void ToggleController(bool showController, VRTK_ControllerActions controllerActions, GameObject obj, float touchDelay)
{
if (showController)
Expand Down
10 changes: 9 additions & 1 deletion Assets/VRTK/Scripts/Interactions/VRTK_InteractHaptics.cs
Expand Up @@ -4,7 +4,7 @@ namespace VRTK
using UnityEngine;

/// <summary>
/// The Interact Haptics script is attached along side the Interactable Object script and provides controller haptics on touch, grab and use of the object.
/// The Interact Haptics script is attached on the same GameObject as an Interactable Object script and provides controller haptics on touch, grab and use of the object.
/// </summary>
public class VRTK_InteractHaptics : MonoBehaviour
{
Expand Down Expand Up @@ -73,6 +73,14 @@ public void HapticsOnUse(VRTK_ControllerActions controllerActions)
}
}

protected virtual void OnEnable()
{
if (!GetComponent<VRTK_InteractableObject>())
{
Debug.LogError("The `VRTK_InteractHaptics` script is required to be attached to a GameObject that has the `VRTK_InteractableObject` script also attached to it.");
}
}

private void TriggerHapticPulse(VRTK_ControllerActions controllerActions, float strength, float duration, float interval)
{
if (controllerActions)
Expand Down
4 changes: 2 additions & 2 deletions DOCUMENTATION.md
Expand Up @@ -2472,7 +2472,7 @@ The ForceResetUsing will force the controller to stop using the currently touche

### Overview

The Interact Haptics script is attached along side the Interactable Object script and provides controller haptics on touch, grab and use of the object.
The Interact Haptics script is attached on the same GameObject as an Interactable Object script and provides controller haptics on touch, grab and use of the object.

### Inspector Parameters

Expand Down Expand Up @@ -2527,7 +2527,7 @@ The HapticsOnUse method triggers the haptic feedback on the given controller for

### Overview

The Interact Controller Appearance script is used to determine whether the controller model should be visible or hidden on touch, grab or use.
The Interact Controller Appearance script is attached on the same GameObject as an Interactable Object script and is used to determine whether the controller model should be visible or hidden on touch, grab or use.

### Inspector Parameters

Expand Down

0 comments on commit bfddccc

Please sign in to comment.