Ejemplo n.º 1
0
    IEnumerator DoAttach()
    {
        while (true)
        {
            var controller = VRTK_DeviceFinder.GetControllerReferenceForHand(controllerHand);

            if (controller == null || !controller.scriptAlias)
            {
                yield return(new WaitForFixedUpdate());

                continue;
            }

            var grab = controller.scriptAlias.GetComponent <VRTK_InteractGrab>();

            if (!grab || !grab.controllerAttachPoint)
            {
                Debug.LogError("Couldn't find attachment point!");
                yield return(new WaitForFixedUpdate());

                continue;
            }

            gameObject.transform.SetParent(grab.controllerAttachPoint.transform);
            gameObject.transform.localPosition = offset;
            gameObject.transform.localRotation = Quaternion.identity;


            var pointer = GetComponent <VRTK_UIPointer>();
            if (pointer)
            {
                pointer.controllerEvents = grab.GetComponent <VRTK_ControllerEvents>();
                pointer.enabled          = true;
            }

            break;
        }
    }