Skip to content

Commit

Permalink
fix(Pointers): clear cached attach point on sdk change
Browse files Browse the repository at this point in the history
The cached attach point on the Base Pointer Renderer was not being
cleared when the SDK was switched so the transform follow script was
not updating to track the new hand type.

This has been fixed by clearing the cache in the `OnEnable` method
and registering the script with the SDKManager toggle method.
  • Loading branch information
thestonefox committed Nov 30, 2017
1 parent a744c1c commit 5d9dcb3
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,15 @@ public virtual GameObject GetObjectInteractor()
protected abstract void DestroyPointerObjects();
protected abstract void ToggleRenderer(bool pointerState, bool actualState);

protected virtual void Awake()
{
VRTK_SDKManager.instance.AddBehaviourToToggleOnLoadedSetupChange(this);
}

protected virtual void OnEnable()
{
cachedPointerAttachPoint = null;
cachedAttachedHand = SDK_BaseController.ControllerHand.None;
defaultMaterial = Resources.Load("WorldPointer") as Material;
makeRendererVisible.Clear();
CreatePointerOriginTransformFollow();
Expand All @@ -291,6 +298,11 @@ protected virtual void OnDisable()
Destroy(pointerOriginTransformFollowGameObject);
}

protected virtual void OnDestroy()
{
VRTK_SDKManager.instance.RemoveBehaviourToToggleOnLoadedSetupChange(this);
}

protected virtual void OnValidate()
{
pointerOriginSmoothingSettings.maxAllowedPerFrameDistanceDifference = Mathf.Max(0.0001f, pointerOriginSmoothingSettings.maxAllowedPerFrameDistanceDifference);
Expand Down

0 comments on commit 5d9dcb3

Please sign in to comment.