Ejemplo n.º 1
0
        void OnEnable()
        {
            ivranimator = (IVR_Animator)target;
            ivr         = ivranimator.GetComponent <InstantVR>();

            if (ivr != null)
            {
                animatorHead = ivr.headTarget.GetComponent <IVR_AnimatorHead>();
                if (animatorHead == null)
                {
                    animatorHead           = ivr.headTarget.gameObject.AddComponent <IVR_AnimatorHead>();
                    animatorHead.extension = ivranimator;
                }

                animatorLeftHand = ivr.leftHandTarget.GetComponent <IVR_AnimatorHand>();
                if (animatorLeftHand == null)
                {
                    animatorLeftHand           = ivr.leftHandTarget.gameObject.AddComponent <IVR_AnimatorHand>();
                    animatorLeftHand.extension = ivranimator;
                }

                animatorRightHand = ivr.rightHandTarget.GetComponent <IVR_AnimatorHand>();
                if (animatorRightHand == null)
                {
                    animatorRightHand           = ivr.rightHandTarget.gameObject.AddComponent <IVR_AnimatorHand>();
                    animatorRightHand.extension = ivranimator;
                }

                animatorHip = ivr.hipTarget.GetComponent <IVR_AnimatorHip>();
                if (animatorHip == null)
                {
                    animatorHip           = ivr.hipTarget.gameObject.AddComponent <IVR_AnimatorHip>();
                    animatorHip.extension = ivranimator;
                }

                animatorLeftFoot = ivr.leftFootTarget.GetComponent <IVR_AnimatorFoot>();
                if (animatorLeftFoot == null)
                {
                    animatorLeftFoot           = ivr.leftFootTarget.gameObject.AddComponent <IVR_AnimatorFoot>();
                    animatorLeftFoot.extension = ivranimator;
                }

                animatorRightFoot = ivr.rightFootTarget.GetComponent <IVR_AnimatorFoot>();
                if (animatorRightFoot == null)
                {
                    animatorRightFoot           = ivr.rightFootTarget.gameObject.AddComponent <IVR_AnimatorFoot>();
                    animatorRightFoot.extension = ivranimator;
                }

                IVR_Extension[] extensions = ivr.GetComponents <IVR_Extension>();
                if (ivranimator.priority == -1)
                {
                    ivranimator.priority = extensions.Length - 1;
                }
                for (int i = 0; i < extensions.Length; i++)
                {
                    if (ivranimator == extensions[i])
                    {
                        while (i < ivranimator.priority)
                        {
                            MoveUp(animatorHead);
                            MoveUp(animatorLeftHand);
                            MoveUp(animatorRightHand);
                            MoveUp(animatorHip);
                            MoveUp(animatorLeftFoot);
                            MoveUp(animatorRightFoot);
                            ivranimator.priority--;
                            //Debug.Log ("Animator Move up to : " + i + " now: " + ivranimator.priority);
                        }
                        while (i > ivranimator.priority)
                        {
                            MoveDown(animatorHead);
                            MoveDown(animatorLeftHand);
                            MoveDown(animatorRightHand);
                            MoveDown(animatorHip);
                            MoveDown(animatorLeftFoot);
                            MoveDown(animatorRightFoot);
                            ivranimator.priority++;
                            //Debug.Log ("Animator Move down to : " + i + " now: " + ivranimator.priority);
                        }
                    }
                }
            }
        }