public void CreateManualAnimationRig() { Dictionary <string, Transform> hAnimLUT = DebugVJointSkeleton(agentSpec.skeleton); if (!hAnimLUT.ContainsKey("HumanoidRoot")) { Debug.LogWarning("Cannot create ManualAnimationRig because Skeleton does not have HumanoidRoot"); } Transform humanoidRoot = hAnimLUT["HumanoidRoot"]; Transform rigParent = humanoidRoot.parent; rigParent.name = "ManualAnimationRig_" + id; rigParent.transform.rotation = transform.rotation; rigParent.transform.position = transform.position + transform.right * 0.5f; ManualAnimationRig rig = rigParent.gameObject.AddComponent <ManualAnimationRig>(); rig.Initialize(this, humanoidRoot, hAnimLUT); }
/* * public bool enableControl = false; * if (enableControl && !ManualAnimation) ManualAnimation = true; * if (!enableControl && ManualAnimation) ManualAnimation = false; * enableControl = ManualAnimation;*/ public void OnEnable() { List <AnimationClip> _animationClips = new List <AnimationClip>(); animationRig = target as ManualAnimationRig; string[] animationLocations = { "Assets/UnityAsapIntegration/Animations" }; string[] clipGUIDs = AssetDatabase.FindAssets("t:AnimationClip", animationLocations); foreach (string guid in clipGUIDs) { string path = AssetDatabase.GUIDToAssetPath(guid); AnimationClip clip = (AnimationClip)AssetDatabase.LoadAssetAtPath(path, typeof(AnimationClip)); _animationClips.Add(clip); } animationClips = _animationClips.ToArray(); animation = animationRig.vjointRoot.parent.gameObject.GetComponent <Animation>(); if (animation == null) { //DestroyImmediate(animation); //Debug.Log("Destroyed..."); animation = animationRig.vjointRoot.parent.gameObject.AddComponent <Animation>(); } /* * foreach (int i = 0; i < animation.GetClipCount(); if++) { * animation.RemoveClip(animation.GetClip() * }*/ /* * foreach (AnimationClip clip in animationClips) { * //clip.legacy = true; * animation.AddClip(clip, clip.name); * }*/ }