Skip to content

Commit

Permalink
fix(Pointers): stop direction indicator working when script disabled
Browse files Browse the repository at this point in the history
The Pointer Direction Indicator will now only work when the script
is active in the current GameObject hierarchy which is useful for
turning the direction indicator on and off by simply disabling a
container parent GameObject.
  • Loading branch information
thestonefox committed Dec 12, 2017
1 parent 564983e commit 6776623
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,15 @@ public virtual Quaternion GetRotation()
/// <param name="validity">Determines if the colour being set is based from a valid location or invalid location.</param>
public virtual void SetMaterialColor(Color color, bool validity)
{
validLocation.SetActive(validity);
invalidLocation.SetActive((displayOnInvalidLocation ? !validity : validity));
if (validLocation != null)
{
validLocation.SetActive(validity);
}

if (invalidLocation != null)
{
invalidLocation.SetActive((displayOnInvalidLocation ? !validity : validity));
}

if (usePointerColor)
{
Expand Down
2 changes: 1 addition & 1 deletion Assets/VRTK/Source/Scripts/Pointers/VRTK_PlayAreaCursor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public virtual void SetPlayAreaCursorTransform(Vector3 location)
headsetOutOfBounds = false;
}
}
playAreaCursor.transform.rotation = (directionIndicator != null ? directionIndicator.transform.rotation : playArea.rotation);
playAreaCursor.transform.rotation = (directionIndicator != null && directionIndicator.gameObject.activeInHierarchy ? directionIndicator.transform.rotation : playArea.rotation);
playAreaCursor.transform.position = location + offset;
}
}
Expand Down
7 changes: 5 additions & 2 deletions Assets/VRTK/Source/Scripts/Pointers/VRTK_Pointer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,10 @@ protected override void OnEnable()
#pragma warning restore 0618
base.OnEnable();
attachedTo = (attachedTo == null ? gameObject : attachedTo);
VRTK_PlayerObject.SetPlayerObject(gameObject, VRTK_PlayerObject.ObjectTypes.Pointer);
if (!VRTK_PlayerObject.IsPlayerObject(gameObject))
{
VRTK_PlayerObject.SetPlayerObject(gameObject, VRTK_PlayerObject.ObjectTypes.Pointer);
}
SetDefaultValues();

if (NoPointerRenderer())
Expand Down Expand Up @@ -389,7 +392,7 @@ protected virtual void HandleEnabledPointer()

protected virtual Quaternion? GetCursorRotation()
{
if (EnabledPointerRenderer() && pointerRenderer.directionIndicator != null)
if (EnabledPointerRenderer() && pointerRenderer.directionIndicator != null && pointerRenderer.directionIndicator.gameObject.activeInHierarchy)
{
return pointerRenderer.directionIndicator.GetRotation();
}
Expand Down

0 comments on commit 6776623

Please sign in to comment.