public override void StartController(InstantVR ivr) { extension = ivr.GetComponent <IVR_Animator>(); base.StartController(ivr); startHipFootL = ivr.hipTarget.InverseTransformPoint(ivr.leftFootTarget.position); startHipFootR = ivr.hipTarget.InverseTransformPoint(ivr.rightFootTarget.position); if (transform == ivr.leftFootTarget) { isLeftFoot = true; leftFoot = this; rightFoot = ivr.rightFootTarget.GetComponent <IVR_AnimatorFoot>(); leftFootAnimation = gameObject.AddComponent <IVR_Animate>(); lastPos = transform.position; startHipFoot = startHipFootL; localStartPosition = ivr.transform.InverseTransformPoint(ivr.leftFootTarget.position); } else { rightFoot = this; leftFoot = ivr.leftFootTarget.GetComponent <IVR_AnimatorFoot>(); rightFootAnimation = gameObject.AddComponent <IVR_Animate>(); lastPos = transform.position; startHipFoot = startHipFootR; localStartPosition = ivr.transform.InverseTransformPoint(ivr.rightFootTarget.position); } startFootLposition = ivr.leftFootTarget.position - transform.position; startFootRposition = ivr.rightFootTarget.position - transform.position; lastHipPosition = ivr.hipTarget.position; }
void OnDestroy() { InstantVR ivr = this.GetComponent <InstantVR>(); if (ivr != null) { IVR_AnimatorHead defaultHead = ivr.headTarget.GetComponent <IVR_AnimatorHead>(); if (defaultHead != null) { DestroyImmediate(defaultHead); } IVR_AnimatorHand defaultLeftHand = ivr.leftHandTarget.GetComponent <IVR_AnimatorHand>(); if (defaultLeftHand != null) { DestroyImmediate(defaultLeftHand); } IVR_AnimatorHand defaultRightHand = ivr.rightHandTarget.GetComponent <IVR_AnimatorHand>(); if (defaultRightHand != null) { DestroyImmediate(defaultRightHand); } IVR_AnimatorHip defaultHip = ivr.hipTarget.GetComponent <IVR_AnimatorHip>(); if (defaultHip != null) { DestroyImmediate(defaultHip); } IVR_AnimatorFoot defaultLeftFoot = ivr.leftFootTarget.GetComponent <IVR_AnimatorFoot>(); if (defaultLeftFoot != null) { DestroyImmediate(defaultLeftFoot); } IVR_AnimatorFoot defaultRightFoot = ivr.rightFootTarget.GetComponent <IVR_AnimatorFoot>(); if (defaultRightFoot != null) { DestroyImmediate(defaultRightFoot); } } }
void OnDestroy() { if (ivranimator == null && ivr != null) { animatorHead = ivr.headTarget.GetComponent <IVR_AnimatorHead>(); if (animatorHead != null) { DestroyImmediate(animatorHead, true); } animatorLeftHand = ivr.leftHandTarget.GetComponent <IVR_AnimatorHand>(); if (animatorLeftHand != null) { DestroyImmediate(animatorLeftHand, true); } animatorRightHand = ivr.rightHandTarget.GetComponent <IVR_AnimatorHand>(); if (animatorRightHand != null) { DestroyImmediate(animatorRightHand, true); } animatorHip = ivr.hipTarget.GetComponent <IVR_AnimatorHip>(); if (animatorHip != null) { DestroyImmediate(animatorHip, true); } animatorLeftFoot = ivr.leftFootTarget.GetComponent <IVR_AnimatorFoot>(); if (animatorLeftFoot != null) { DestroyImmediate(animatorLeftFoot, true); } animatorRightFoot = ivr.rightFootTarget.GetComponent <IVR_AnimatorFoot>(); if (animatorRightFoot != null) { DestroyImmediate(animatorRightFoot, true); } } }
void OnEnable() { ivranimator = (IVR_Animator)target; if (!ivranimator) { return; } 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); } } } } }