public void Initialize( string name, SharedAnimationData sharedData) { Name = name; this.sharedData = sharedData; boneHandles = sharedData.GetBoneHandlesCopy(); boneWeights = sharedData.GetBoneWeightsCopy(); if (BoneTransformWeights == null || BoneTransformWeights.Count == 0 || BoneTransformWeights[0].transform == null) { var defaultBoneWeight = new BoneTransformWeight { // TODO remove this hardcoded default transform = sharedData.Animatable.RootTransform, weight = 1f, }; if (BoneTransformWeights == null) { BoneTransformWeights = new List <BoneTransformWeight>(); } else if (BoneTransformWeights.Count == 0) { BoneTransformWeights.Add(defaultBoneWeight); } else { BoneTransformWeights[0] = defaultBoneWeight; } } // Set bone weights for selected transforms and their hierarchy. boneChildrenIndices = new List <List <int> >(BoneTransformWeights.Count); foreach (var boneTransform in BoneTransformWeights) { var childrenTransforms = boneTransform.transform.GetComponentsInChildren <Transform>(); var childrenIndices = new List <int>(childrenTransforms.Length); foreach (var childTransform in childrenTransforms) { var boneIndex = Array.IndexOf(sharedData.AllAnimatorTransforms, childTransform); Debug.Assert(boneIndex > 0, "Index can't be less or equal to 0"); childrenIndices.Add(boneIndex - 1); } boneChildrenIndices.Add(childrenIndices); } scriptPlayable = InitializePlayable(); }
public AnimationLayer(string name, SharedAnimationData sharedData, AnimationClip defaultPose, bool isAdditive, float layerWeight, AvatarMask layerMask) { Name = name; this.sharedData = sharedData; this.defaultPose = defaultPose; this.isAdditive = isAdditive; this.layerWeight = layerWeight; this.layerMask = layerMask; // Debug.Log($"Init animation layer, {Name}"); // mixerPlayable = AnimationMixerPlayable.Create(sharedData.PlayableGraph, 2); defaultPlayable = AnimationClipPlayable.Create(this.sharedData.PlayableGraph, defaultPose); mixerRunner = new MixerRunner(); }