void DestroyPreview() { if (m_previewInstance != null) { GameObject.DestroyImmediate(m_previewInstance.gameObject); m_previewInstance = null; } }
private void UpdatePreview(bool preview, bool isRetained) { if (PreviewInstance && !isRetained) { DestroyImmediate(PreviewInstance); serializedObject.ApplyModifiedProperties(); } if (!preview) { return; } if (isRetained && SP_HandPreview.objectReferenceValue != null) { return; } var source = IsLeft ? HVRSettings.Instance.RightHand : HVRSettings.Instance.LeftHand; var previewName = $"Mirror [{ThisHand.gameObject.name}]"; var existing = GameObject.Find(previewName); if (existing) { PreviewInstance = existing; } else { PreviewInstance = Instantiate(source, ThisHand.transform.parent, false); PreviewInstance.name = previewName; } var hand = PreviewInstance.GetComponent <HVRPosableHand>(); hand.DoPreview = false; hand.IsLeft = !ThisHand.IsLeft; serializedObject.ApplyModifiedProperties(); if (hand != null) { var mirror = ThisHand.Mirror(MirrorAxis.X); var snapShot = ThisHand.CreateHandPose(); //var mirror = snapShot.Mirror(ThisHand.MirrorAxis, ThisHand.transform); //hand.FingerSetup(); hand.Pose(mirror); SceneView.RepaintAll(); } else { Debug.Log($"Preview hand is missing VRPosableHand"); } }