Skip to content

Commit

Permalink
Merge pull request ExtendRealityLtd#1426 from thestonefox/fix/snap-dr…
Browse files Browse the repository at this point in the history
…op-zone-highlighting

fix(SnapDropZone): ensure highlight always active option is honoured - fixes ExtendRealityLtd#1421
  • Loading branch information
thestonefox authored Aug 15, 2017
2 parents 7faa964 + 9e70764 commit 73c48f8
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions Assets/VRTK/Prefabs/Resources/Scripts/VRTK_SnapDropZone.cs
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,12 @@ protected virtual void SetObjectHighlight()
{
if (highlightAlwaysActive && !isSnapped && !isHighlighted)
{
highlightObject.SetActive(true);
SetHighlightObjectActive(true);
}

if (!highlightAlwaysActive && isHighlighted && !ValidSnappableObjectIsHovering())
{
SetHighlightObjectActive(false);
}
}

Expand Down Expand Up @@ -404,7 +409,7 @@ protected virtual void CheckCurrentValidSnapObjectStillValid()
RemoveCurrentValidSnapObject(currentIOCheck);
if (isHighlighted && highlightObject != null && !highlightAlwaysActive)
{
highlightObject.SetActive(false);
SetHighlightObjectActive(false);
}
}
}
Expand Down Expand Up @@ -473,7 +478,7 @@ protected virtual void SnapObject(Collider collider)
if (highlightObject != null)
{
//Turn off the drop zone highlighter
highlightObject.SetActive(false);
SetHighlightObjectActive(false);
}

Vector3 newLocalScale = GetNewLocalScale(ioCheck);
Expand Down Expand Up @@ -729,11 +734,10 @@ protected virtual void ToggleHighlight(Collider collider, bool state)
if (highlightObject != null && ioCheck != null)
{
//Toggle the highlighter state
highlightObject.SetActive(state);
SetHighlightObjectActive(state);
ioCheck.SetSnapDropZoneHover(this, state);

willSnap = state;
isHighlighted = state;

if (state)
{
Expand Down Expand Up @@ -789,11 +793,17 @@ protected virtual void GenerateHighlightObject()
DeleteHighlightObject();
}

SetHighlightObjectActive(false);
SetContainer();
}

protected virtual void SetHighlightObjectActive(bool state)
{
if (highlightObject != null)
{
highlightObject.SetActive(false);
highlightObject.SetActive(state);
isHighlighted = state;
}
SetContainer();
}

protected virtual void DeleteHighlightObject()
Expand Down

0 comments on commit 73c48f8

Please sign in to comment.