Skip to content

Commit 5d9dcb3

Browse files
committed
fix(Pointers): clear cached attach point on sdk change
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.
1 parent a744c1c commit 5d9dcb3

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Assets/VRTK/Source/Scripts/Pointers/PointerRenderers/VRTK_BasePointerRenderer.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,15 @@ public virtual GameObject GetObjectInteractor()
272272
protected abstract void DestroyPointerObjects();
273273
protected abstract void ToggleRenderer(bool pointerState, bool actualState);
274274

275+
protected virtual void Awake()
276+
{
277+
VRTK_SDKManager.instance.AddBehaviourToToggleOnLoadedSetupChange(this);
278+
}
279+
275280
protected virtual void OnEnable()
276281
{
282+
cachedPointerAttachPoint = null;
283+
cachedAttachedHand = SDK_BaseController.ControllerHand.None;
277284
defaultMaterial = Resources.Load("WorldPointer") as Material;
278285
makeRendererVisible.Clear();
279286
CreatePointerOriginTransformFollow();
@@ -291,6 +298,11 @@ protected virtual void OnDisable()
291298
Destroy(pointerOriginTransformFollowGameObject);
292299
}
293300

301+
protected virtual void OnDestroy()
302+
{
303+
VRTK_SDKManager.instance.RemoveBehaviourToToggleOnLoadedSetupChange(this);
304+
}
305+
294306
protected virtual void OnValidate()
295307
{
296308
pointerOriginSmoothingSettings.maxAllowedPerFrameDistanceDifference = Mathf.Max(0.0001f, pointerOriginSmoothingSettings.maxAllowedPerFrameDistanceDifference);

0 commit comments

Comments
 (0)