/// <summary> /// Called by the Timeline Editor to gather properties requiring preview. /// </summary> /// <param name="director">The PlayableDirector invoking the preview</param> /// <param name="driver">PropertyCollector used to gather previewable properties</param> public override void GatherProperties(PlayableDirector director, IPropertyCollector driver) { #if UNITY_EDITOR m_SceneOffsetPosition = Vector3.zero; m_SceneOffsetRotation = Vector3.zero; var animator = GetBinding(director); if (animator == null) { return; } var animClips = new List <AnimationClip>(this.clips.Length + 2); GetAnimationClips(animClips); var hasHumanMotion = animClips.Exists(clip => clip.humanMotion); m_SceneOffsetPosition = animator.transform.localPosition; m_SceneOffsetRotation = animator.transform.localEulerAngles; // Create default pose clip from collected properties if (hasHumanMotion) { animClips.Add(GetDefaultHumanoidClip()); } var bindings = AnimationPreviewUtilities.GetBindings(animator.gameObject, animClips); m_CachedPropertiesClip = AnimationPreviewUtilities.CreateDefaultClip(animator.gameObject, bindings); AnimationPreviewUtilities.PreviewFromCurves(animator.gameObject, bindings); // faster to preview from curves then an animation clip m_DefaultPoseClip = hasHumanMotion ? GetDefaultHumanoidClip() : null; #endif }
/// <summary> /// Called by the Timeline Editor to gather properties requiring preview. /// </summary> /// <param name="director">The PlayableDirector invoking the preview</param> /// <param name="driver">PropertyCollector used to gather previewable properties</param> public override void GatherProperties(PlayableDirector director, IPropertyCollector driver) { #if UNITY_EDITOR m_SceneOffsetPosition = Vector3.zero; m_SceneOffsetRotation = Vector3.zero; var animator = GetBinding(director); if (animator == null) { return; } var animClips = new List <AnimationClip>(this.clips.Length + 2); GetAnimationClips(animClips); var hasHumanMotion = animClips.Exists(clip => clip.humanMotion); // case 1174752 - recording root transform on humanoid clips clips cause invalid pose. This will apply the default T-Pose, only if it not already driven by another track if (!hasHumanMotion && animator.isHuman && AnimatesRootTransform() && !DrivenPropertyManagerInternal.IsDriven(animator.transform, "m_LocalPosition.x") && !DrivenPropertyManagerInternal.IsDriven(animator.transform, "m_LocalRotation.x")) { hasHumanMotion = true; } m_SceneOffsetPosition = animator.transform.localPosition; m_SceneOffsetRotation = animator.transform.localEulerAngles; // Create default pose clip from collected properties if (hasHumanMotion) { animClips.Add(GetDefaultHumanoidClip()); } m_DefaultPoseClip = hasHumanMotion ? GetDefaultHumanoidClip() : null; var hash = AnimationPreviewUtilities.GetClipHash(animClips); if (m_CachedBindings == null || m_CachedHash != hash) { m_CachedBindings = AnimationPreviewUtilities.GetBindings(animator.gameObject, animClips); m_CachedPropertiesClip = AnimationPreviewUtilities.CreateDefaultClip(animator.gameObject, m_CachedBindings); m_CachedHash = hash; } AnimationPreviewUtilities.PreviewFromCurves(animator.gameObject, m_CachedBindings); // faster to preview from curves then an animation clip #endif }
private static void UpdateTransformBindings(EditorCurveBinding[] bindings) { for (int i = 0; i < bindings.Length; i++) { var binding = bindings[i]; if (AnimationPreviewUtilities.IsRootMotion(binding)) { binding.type = typeof(Transform); binding.propertyName = TRPlaceHolder; } else if (typeof(Transform).IsAssignableFrom(binding.type) && (binding.propertyName.StartsWith("m_LocalRotation.") || binding.propertyName.StartsWith("m_LocalPosition."))) { binding.propertyName = TRPlaceHolder; } else if (typeof(Transform).IsAssignableFrom(binding.type) && binding.propertyName.StartsWith("m_LocalScale.")) { binding.propertyName = ScalePlaceholder; } bindings[i] = binding; } }