Ejemplo n.º 1
0
        protected virtual void Awake()
        {
            //find the Animator somewhere in this gameobject's hierarchy
            if (animator == null)
            {
                Transform t = transform;
                while (t != null)
                {
                    if (t.gameObject.GetComponent <Animator>())
                    {
                        animator = t.gameObject.GetComponent <Animator>();
                        rootNode = t.gameObject;
                        break;
                    }
                    t = t.parent;
                }
                if (animator == null)
                {
                    Debug.LogError("IKOrionLeapHandController:: no animator found on GameObject or any of its parent transforms. Are you sure you added IKLeapHandController to a properly defined rigged avatar?");
                }
            }

            if (leftHand == null && avatarLeftHand != null)
            {
                leftHand = avatarLeftHand.GetComponent <RiggedHand>();
            }
            if (rightHand == null && avatarRightHand != null)
            {
                rightHand = avatarRightHand.GetComponent <RiggedHand>();
            }

            if (leftHand == null)
            {
                Debug.LogError("IKOrionLeapHandController::Awake::No Rigged Hand set for left hand parameter. You have to set this in the inspector.");
            }
            else
            {
                leftHand.BeginHand();
            }
            if (rightHand == null)
            {
                Debug.LogError("IKOrionLeapHandController::Awake::No Rigged Hand set for right hand parameter. You have to set this in the inspector.");
            }
            else
            {
                rightHand.BeginHand();
            }

            if (leftPhysicsHand != null)
            {
                if (leftHand != null)
                {
                    leftPhysicsHand.targetHand = leftHand;
                }
            }
            if (rightPhysicsHand != null)
            {
                if (rightHand != null)
                {
                    rightPhysicsHand.targetHand = rightHand;
                }
            }
        }