동글 운항
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// Author MikeNspired.
|
||||
// Author MikeNspired.
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.XR.Interaction.Toolkit.Interactables;
|
||||
@@ -41,8 +41,25 @@ protected virtual void Awake()
|
||||
{
|
||||
CreateTransforms();
|
||||
}
|
||||
|
||||
HidePreviewHandsInPlayMode();
|
||||
}
|
||||
|
||||
|
||||
private void HidePreviewHandsInPlayMode()
|
||||
{
|
||||
if (!Application.isPlaying)
|
||||
return;
|
||||
|
||||
foreach (HandAnimator hand in GetComponentsInChildren<HandAnimator>(true))
|
||||
{
|
||||
if (hand != null)
|
||||
hand.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
currentLeftHand = null;
|
||||
currentRightHand = null;
|
||||
}
|
||||
//Determine which hand is being grabbed to send the hand animator the proper poses for the hand.
|
||||
protected virtual void BeginNewHandPoses(HandAnimator hand)
|
||||
{
|
||||
|
||||
@@ -72,9 +72,15 @@ private void OnGrab(SelectEnterEventArgs args)
|
||||
|
||||
private void FindHandPoser(SelectEnterEventArgs args)
|
||||
{
|
||||
Transform interactableTransform = args.interactableObject.transform;
|
||||
|
||||
currentHandPoser =
|
||||
args.interactableObject.transform.GetComponent<XRHandPoser>() ??
|
||||
args.interactableObject.transform.GetComponentInChildren<XRHandPoser>();
|
||||
interactableTransform.GetComponent<XRHandPoser>() ??
|
||||
interactableTransform.GetComponentInChildren<XRHandPoser>(true) ??
|
||||
interactableTransform.GetComponentInParent<XRHandPoser>();
|
||||
|
||||
if (!currentHandPoser && interactableTransform.parent)
|
||||
currentHandPoser = interactableTransform.parent.GetComponentInChildren<XRHandPoser>(true);
|
||||
}
|
||||
|
||||
public void ResetAttachTransform()
|
||||
|
||||
@@ -23,7 +23,8 @@ protected override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
OnValidate();
|
||||
SubscribeToSelection();
|
||||
if (interactable)
|
||||
SubscribeToSelection();
|
||||
}
|
||||
|
||||
private void SubscribeToSelection()
|
||||
@@ -91,12 +92,26 @@ private float GetEaseInTime()
|
||||
|
||||
return time;
|
||||
}
|
||||
|
||||
private XRBaseInteractable FindInteractableInAncestorChildren()
|
||||
{
|
||||
for (Transform parent = transform.parent; parent != null; parent = parent.parent)
|
||||
{
|
||||
XRBaseInteractable foundInteractable = parent.GetComponentInChildren<XRBaseInteractable>(true);
|
||||
if (foundInteractable != null)
|
||||
return foundInteractable;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
private void OnValidate()
|
||||
{
|
||||
if (!interactable)
|
||||
interactable = GetComponent<XRBaseInteractable>();
|
||||
if (!interactable)
|
||||
interactable = GetComponentInParent<XRBaseInteractable>();
|
||||
if (!interactable)
|
||||
interactable = FindInteractableInAncestorChildren();
|
||||
if (!interactable)
|
||||
Debug.LogWarning(gameObject + " XRGrabPoser does not have an XRGrabInteractable assigned." + " (Parent name) " + transform.parent);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user