Skip to content

Commit

Permalink
feat(Interaction): remove global touch highlight option
Browse files Browse the repository at this point in the history
  > ** Breaking Changes **

The Global Touch Highlight Color option on the Interact Touch script
has now been removed as it is somewhat redundant as each Interactable
Object can have a colour set on it individually or multiple objects
can be selected and have the colour set on all of them together.

Having similar options in multiple places causes confusion with what
overrides what.

The Interactable Object also now just has a Touch Highlight Color
option and no longer has a toggle. If there is no highlight colour
required then the colour should be set to `Color.clear` which is
`#00000000` as this will then be ignored when attempting to highlight.
  • Loading branch information
thestonefox committed Nov 10, 2016
1 parent 36c0f9d commit f755e23
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 50 deletions.
10 changes: 2 additions & 8 deletions Assets/VRTK/Editor/VRTK_InteractableObjectEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,7 @@ public override void OnInspectorGUI()
if (viewTouch)
{
EditorGUI.indentLevel++;

targ.highlightOnTouch = EditorGUILayout.Toggle(VRTK_EditorUtilities.BuildGUIContent<VRTK_InteractableObject>("highlightOnTouch"), targ.highlightOnTouch);
if (targ.highlightOnTouch)
{
EditorGUILayout.PropertyField(serializedObject.FindProperty("touchHighlightColor"));
}

EditorGUILayout.PropertyField(serializedObject.FindProperty("touchHighlightColor"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("allowedTouchControllers"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("hideControllerOnTouch"));

Expand Down Expand Up @@ -71,7 +65,7 @@ public override void OnInspectorGUI()

EditorGUILayout.PropertyField(serializedObject.FindProperty("validDrop"));
targ.secondaryGrabAction = (VRTK_InteractableObject.SecondaryControllerActions)EditorGUILayout.EnumPopup(VRTK_EditorUtilities.BuildGUIContent<VRTK_InteractableObject>("secondaryGrabAction"), targ.secondaryGrabAction);
if(targ.secondaryGrabAction == VRTK_InteractableObject.SecondaryControllerActions.Custom_Action)
if (targ.secondaryGrabAction == VRTK_InteractableObject.SecondaryControllerActions.Custom_Action)
{
EditorGUILayout.PropertyField(serializedObject.FindProperty("customSecondaryAction"));
}
Expand Down
4 changes: 1 addition & 3 deletions Assets/VRTK/Scripts/VRTK_InteractTouch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ public class VRTK_InteractTouch : MonoBehaviour
public bool hideControllerOnTouch = false;
[Tooltip("The amount of seconds to wait before hiding the controller on touch.")]
public float hideControllerDelay = 0f;
[Tooltip("If the interactable object can be highlighted when it's touched but no local colour is set then this global colour is used.")]
public Color globalTouchHighlightColor = Color.clear;
[Tooltip("If a custom rigidbody and collider for the rigidbody are required, then a gameobject containing a rigidbody and collider can be passed into this parameter. If this is empty then the rigidbody and collider will be auto generated at runtime to match the HTC Vive default controller.")]
public GameObject customRigidbodyObject;

Expand Down Expand Up @@ -299,7 +297,7 @@ private void OnTriggerStay(Collider collider)
StoreTouchedObjectColliders(collider);
CheckButtonOverrides(touchedObjectScript);

touchedObjectScript.ToggleHighlight(true, globalTouchHighlightColor);
touchedObjectScript.ToggleHighlight(true);

OnControllerTouchInteractableObject(SetControllerInteractEvent(touchedObject));
touchedObjectScript.StartTouching(gameObject);
Expand Down
30 changes: 6 additions & 24 deletions Assets/VRTK/Scripts/VRTK_InteractableObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ public enum SecondaryControllerActions

[Header("Touch Interactions", order = 1)]

[Tooltip("The object will only highlight when a controller touches it if this is checked.")]
public bool highlightOnTouch = false;
[Tooltip("The colour to highlight the object when it is touched. This colour will override any globally set colour (for instance on the `VRTK_InteractTouch` script).")]
public Color touchHighlightColor = Color.clear;
[Tooltip("Determines which controller can initiate a touch action.")]
Expand All @@ -128,7 +126,7 @@ public enum SecondaryControllerActions
[Tooltip("Determines what should happen to the object if another grab attempt is made by a secondary controller if the object is already being grabbed.")]
public SecondaryControllerActions secondaryGrabAction = SecondaryControllerActions.Swap_Controller;
[Tooltip("The script to utilise to process the secondary controller action when a secondary grab attempt is made.")]
public VRTK.SecondaryControllerGrabActions.VRTK_BaseGrabAction customSecondaryAction;
public SecondaryControllerGrabActions.VRTK_BaseGrabAction customSecondaryAction;
[Tooltip("If this is checked then the grab button on the controller needs to be continually held down to keep grabbing. If this is unchecked the grab button toggles the grab action with one button press to grab and another to release.")]
public bool holdButtonToGrab = true;
[Tooltip("If this is set to `Undefined` then the global grab alias button will grab the object, setting it to any other button will ensure the override button is used to grab this specific interactable object.")]
Expand Down Expand Up @@ -428,34 +426,18 @@ public virtual void StopUsing(GameObject previousUsingObject)
}

/// <summary>
/// The ToggleHighlight/1 method is used as a shortcut to disable highlights whilst keeping the same method signature. It should always be used with `false` and it calls ToggleHighlight/2 with a `Color.clear`.
/// The ToggleHighlight method is used to turn on or off the colour highlight of the object.
/// </summary>
/// <param name="toggle">The state to determine whether to activate or deactivate the highlight. `true` will enable the highlight and `false` will remove the highlight.</param>
public virtual void ToggleHighlight(bool toggle)
{
ToggleHighlight(toggle, Color.clear);
}
InitialiseHighlighter();

/// <summary>
/// The ToggleHighlight/2 method is used to turn on or off the colour highlight of the object.
/// </summary>
/// <param name="toggle">The state to determine whether to activate or deactivate the highlight. `true` will enable the highlight and `false` will remove the highlight.</param>
/// <param name="globalHighlightColor">The colour to use when highlighting the object.</param>
public virtual void ToggleHighlight(bool toggle, Color globalHighlightColor)
{
if (highlightOnTouch && objectHighlighter == null)
{
InitialiseHighlighter();
}
if (objectHighlighter && highlightOnTouch)
if (touchHighlightColor != Color.clear && objectHighlighter)
{
if (toggle && !IsGrabbed())
{
Color color = (touchHighlightColor != Color.clear ? touchHighlightColor : globalHighlightColor);
if (color != Color.clear)
{
objectHighlighter.Highlight(color);
}
objectHighlighter.Highlight(touchHighlightColor);
}
else
{
Expand Down Expand Up @@ -872,7 +854,7 @@ protected virtual void LoadPreviousState()

protected virtual void InitialiseHighlighter()
{
if (highlightOnTouch)
if (touchHighlightColor != Color.clear && !objectHighlighter)
{
autoHighlighter = false;
objectHighlighter = Utilities.GetActiveHighlighter(gameObject);
Expand Down
16 changes: 1 addition & 15 deletions DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -2663,7 +2663,6 @@ The highlighting of an Interactable Object is defaulted to use the `VRTK_Materia

### Inspector Parameters

* **Highlight On Touch:** The object will only highlight when a controller touches it if this is checked.
* **Touch Highlight Color:** The colour to highlight the object when it is touched. This colour will override any globally set colour (for instance on the `VRTK_InteractTouch` script).
* **Allowed Touch Controllers:** Determines which controller can initiate a touch action.
* **Hide Controller On Touch:** Optionally override the controller setting.
Expand Down Expand Up @@ -2866,19 +2865,7 @@ The StopUsing method is called automatically when the object has stopped being u
* Returns
* _none_

The ToggleHighlight/1 method is used as a shortcut to disable highlights whilst keeping the same method signature. It should always be used with `false` and it calls ToggleHighlight/2 with a `Color.clear`.

#### ToggleHighlight/2

> `public virtual void ToggleHighlight(bool toggle, Color globalHighlightColor)`
* Parameters
* `bool toggle` - The state to determine whether to activate or deactivate the highlight. `true` will enable the highlight and `false` will remove the highlight.
* `Color globalHighlightColor` - The colour to use when highlighting the object.
* Returns
* _none_

The ToggleHighlight/2 method is used to turn on or off the colour highlight of the object.
The ToggleHighlight method is used to turn on or off the colour highlight of the object.

#### PauseCollisions/0

Expand Down Expand Up @@ -3197,7 +3184,6 @@ The Interact Touch script is attached to a Controller object within the `[Camera

* **Hide Controller On Touch:** Hides the controller model when a valid touch occurs.
* **Hide Controller Delay:** The amount of seconds to wait before hiding the controller on touch.
* **Global Touch Highlight Color:** If the interactable object can be highlighted when it's touched but no local colour is set then this global colour is used.
* **Custom Rigidbody Object:** If a custom rigidbody and collider for the rigidbody are required, then a gameobject containing a rigidbody and collider can be passed into this parameter. If this is empty then the rigidbody and collider will be auto generated at runtime to match the HTC Vive default controller.

### Class Events
Expand Down

0 comments on commit f755e23

Please sign in to comment.