using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEditor; public class createRotationOffset : MonoBehaviour { public Transform referenceHips; public Transform avatarHips; public Transform referenceSpine; public Transform avatarSpine; public Transform referenceLeftLeg; public Transform avatarLeftLeg; public GameObject userAvatar; bool started; // Use this for initialization void Start() { Debug.Log("reference hips rotation" + referenceHips.rotation); Debug.Log("avatar hips rotation" + avatarHips.rotation); Quaternion offset = Quaternion.Inverse(avatarHips.rotation) * referenceHips.rotation; Debug.Log("offset Hips rotation" + offset); Debug.Log("reference spine rotation" + referenceSpine.rotation); Debug.Log("avatar spine rotation" + avatarSpine.rotation); Quaternion offset2 = Quaternion.Inverse(avatarSpine.rotation) * referenceSpine.rotation; Debug.Log("offset Spine rotation" + offset2); Debug.Log("reference leftupleg rotation" + referenceLeftLeg.rotation); Debug.Log("avatar leftleg rotation" + avatarLeftLeg.rotation); Quaternion offset3 = Quaternion.Inverse(avatarLeftLeg.rotation) * referenceLeftLeg.rotation; Debug.Log("offset LeftLeg rotation" + offset3); started = false; } // Update is called once per frame void Update () { if (started == false) { started = true; if (userAvatar != null) { Debug.Log("trying to import"); AssetImporter importer = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(userAvatar)); if (importer != null) { ModelImporter modelImporter = importer as ModelImporter; if (modelImporter != null) { Debug.Log("model importer"); HumanDescription avatarDescription = modelImporter.humanDescription; HumanBone[] bonemap = avatarDescription.human; foreach (HumanBone bone in bonemap){ Debug.Log(bone.boneName + " : " + bone.humanName); } } Debug.Log("we imported the file"); } else { Debug.Log("didn't find the file"); } } } } }