private object CreateAnimator(object animationData, string aniName = null) { if (animationData is RepeatableFrameAnimationData) { var aniData = (RepeatableFrameAnimationData)animationData; var animator = new RepeatableFrameAnimator(aniData); return(animator); } else if (animationData is FrameAnimationData) { var aniData = (FrameAnimationData)animationData; var animator = new FrameAnimator(aniData); return(animator); } else if (animationData is SpineAnimationData) { var aniData = (SpineAnimationData)animationData; var animator = new SpineAnimator(aniData); if (aniName != null) { animator.SelectedAnimationName = aniName; } return(animator); } return(null); }
private void Start() { _spineAnimator = GetComponent <SpineAnimator>(); ISkeletonAnimation s = _spineAnimator.GetSkeletonAnimation() as ISkeletonAnimation; if (s != null) { s.UpdateLocal += HandleUpdateLocal; } IAnimationStateComponent sa = _spineAnimator.GetSkeletonAnimation() as IAnimationStateComponent; if (sa != null) { this._state = sa.AnimationState; } SetSourceBone(_sourceBoneName); Skeleton skeleton = s.Skeleton; _siblingBones.Clear(); foreach (string bn in _siblingBoneNames) { Bone b = skeleton.FindBone(bn); if (b != null) { _siblingBones.Add(b); } } }
private void CacheAnimator(Animator animator) { if (_animator == null) { _animator = animator.GetComponent <SpineAnimator>(); } }
public override void ProcessFrame(Playable playable, FrameData info, object playerData) { if (_trackBinding != null && _animationStates != null) { for (int i = 0; i < _animationStates.Length; i++) { Spine3DAnimationSet animationSet = _trackBinding._renderer._animationSets[i]; ApplyChannelsToState(animationSet, _animationStates[i]); } #if UNITY_EDITOR if (!Application.isPlaying) { ApplyInEditor(); } else #endif { for (int i = 0; i < _animationStates.Length; i++) { SpineAnimator spineAnimator = _trackBinding._renderer._animationSets[i]._animatior; _animationStates[i].Apply(spineAnimator.GetSkeletonAnimation().Skeleton); } } } }
public void StopAll() { for (int i = 0; i < _renderer._animationSets.Length; i++) { SpineAnimator childAnimator = _renderer._animationSets[i]._animatior; childAnimator.StopAll(); } }
public void SetAnimationNormalizedSpeed(int channel, string animName, float speed) { for (int i = 0; i < _renderer._animationSets.Length; i++) { SpineAnimator childAnimator = _renderer._animationSets[i]._animatior; childAnimator.SetAnimationNormalizedSpeed(channel, GetAnimNameForAnimationSet(_renderer._animationSets[i], animName), speed); } }
public void Play(int channel, string animName, WrapMode wrapMode = WrapMode.Default, float blendTime = 0.0f, InterpolationType easeType = InterpolationType.InOutSine, float weight = 1.0f, bool queued = false) { for (int i = 0; i < _renderer._animationSets.Length; i++) { SpineAnimator childAnimator = _renderer._animationSets[i]._animatior; childAnimator.Play(channel, GetAnimNameForAnimationSet(_renderer._animationSets[i], animName), wrapMode, blendTime, easeType, weight, queued); } }
public void SetAnimationWeight(int channel, string animName, float weight) { for (int i = 0; i < _renderer._animationSets.Length; i++) { SpineAnimator childAnimator = _renderer._animationSets[i]._animatior; childAnimator.SetAnimationWeight(channel, GetAnimNameForAnimationSet(_renderer._animationSets[i], animName), weight); } }
public void Stop(int channel, float blendTime = 0.0f, InterpolationType easeType = InterpolationType.InOutSine) { for (int i = 0; i < _renderer._animationSets.Length; i++) { SpineAnimator childAnimator = _renderer._animationSets[i]._animatior; childAnimator.Stop(channel, blendTime, easeType); } }
private void ApplyInEditor() { for (int i = 0; i < _animationStates.Length; i++) { SpineAnimator spineAnimator = _trackBinding._renderer._animationSets[i]._animatior; spineAnimator.GetSkeletonAnimation().Skeleton.SetToSetupPose(); _animationStates[i].Apply(spineAnimator.GetSkeletonAnimation().Skeleton); } }
public float GetAnimationNormalizedSpeed(int channel, string animName) { float speed = 1.0f; for (int i = 0; i < _renderer._animationSets.Length; i++) { SpineAnimator childAnimator = _renderer._animationSets[i]._animatior; speed = Mathf.Max(childAnimator.GetAnimationNormalizedSpeed(channel, GetAnimNameForAnimationSet(_renderer._animationSets[i], animName)), speed); } return(speed); }
public float GetAnimationNormalizedTime(int channel, string animName) { float time = 0.0f; for (int i = 0; i < _renderer._animationSets.Length; i++) { SpineAnimator childAnimator = _renderer._animationSets[i]._animatior; time = Mathf.Max(childAnimator.GetAnimationNormalizedTime(channel, GetAnimNameForAnimationSet(_renderer._animationSets[i], animName)), time); } return(time); }
public float GetAnimationWeight(int channel, string animName) { float weight = 0.0f; for (int i = 0; i < _renderer._animationSets.Length; i++) { SpineAnimator childAnimator = _renderer._animationSets[i]._animatior; weight = Mathf.Max(childAnimator.GetAnimationWeight(channel, GetAnimNameForAnimationSet(_renderer._animationSets[i], animName)), weight); } return(weight); }
public float GetAnimationLength(string animName) { float length = 0.0f; for (int i = 0; i < _renderer._animationSets.Length; i++) { SpineAnimator childAnimator = _renderer._animationSets[i]._animatior; length = Mathf.Max(childAnimator.GetAnimationLength(GetAnimNameForAnimationSet(_renderer._animationSets[i], animName)), length); } return(length); }
private static void OnSelectionChanged() { if (Selection.activeGameObject != null) { SpineAnimator animator = Selection.activeGameObject.GetComponent <SpineAnimator>(); if (animator != null) { _animator = animator; } } }
public bool DoesAnimationExist(string animName) { for (int i = 0; i < _renderer._animationSets.Length; i++) { SpineAnimator childAnimator = _renderer._animationSets[i]._animatior; if (!childAnimator.DoesAnimationExist(GetAnimNameForAnimationSet(_renderer._animationSets[i], animName))) { return(false); } } return(true); }
public bool IsPlaying(int channel, string animName) { for (int i = 0; i < _renderer._animationSets.Length; i++) { SpineAnimator childAnimator = _renderer._animationSets[i]._animatior; if (childAnimator.IsPlaying(channel, GetAnimNameForAnimationSet(_renderer._animationSets[i], animName))) { return(true); } } return(false); }
public string GetAnimNameForAnimationSet(Spine3DAnimationSet animationSet, string animName) { if (!string.IsNullOrEmpty(animationSet._animationPrefix)) { SpineAnimator childAnimator = animationSet._animatior; string fullAnimName = animName + animationSet._animationPrefix; if (childAnimator.DoesAnimationExist(fullAnimName)) { return(fullAnimName); } } return(animName); }
public int AddSpine(SpineAnimator sa) { roots[numJobs] = numBones; transforms.Add(sa.gameObject.transform); damping[numJobs] = sa.damping; boneCount[numJobs] = sa.children.Count + 1; for (int i = 0; i < sa.children.Count; i++) { transforms.Add(sa.children[i]); offsets[numBones + i + 1] = sa.offsets[i]; // No offset for the 0th } numJobs++; numBones += sa.children.Count + 1; return(numJobs - 1); }
public void SetTrackAsset(TrackAsset trackAsset, PlayableDirector playableDirector) { _trackAsset = trackAsset as Spine3DAnimatorTrack; _director = playableDirector; _trackBinding = _director.GetGenericBinding(trackAsset) as Spine3DAnimator; if (_trackBinding != null) { _animationStates = new AnimationState[_trackBinding._renderer._animationSets.Length]; for (int i = 0; i < _animationStates.Length; i++) { SpineAnimator spineAnimator = _trackBinding._renderer._animationSets[i]._animatior; _animationStates[i] = new AnimationState(spineAnimator.GetSkeletonAnimation().SkeletonDataAsset.GetAnimationStateData()); } } }
public void Draw(SpineAnimator animator, Matrix world) { Spine.Skeleton skeleton = animator.Skeleton; if (skeleton != null) { if (animator.Position != Point.Zero) { world *= Matrix.CreateTranslation(animator.Position.X, animator.Position.Y, 0); } spineRenderer.PremultipliedAlpha = animator.Data.PremultipliedAlpha; spineRenderer.Effect.World = world; skeleton.X = 0; skeleton.Y = 0; spineRenderer.Begin(); spineRenderer.Draw(animator.Skeleton); spineRenderer.End(); } }
public string[] GetAnimationNames() { HashSet <string> animationNames = new HashSet <string>(); for (int i = 0; i < _renderer._animationSets.Length; i++) { SpineAnimator childAnimator = _renderer._animationSets[i]._animatior; string[] childAnimationNames = childAnimator.GetAnimationNames(); foreach (string childAnimationName in childAnimationNames) { animationNames.Add(childAnimationName); } } string[] stringArray = new string[animationNames.Count]; animationNames.CopyTo(stringArray); return(stringArray); }
public override void OnInspectorGUI() { SerializedProperty animationIdProperty = serializedObject.FindProperty("_animationName"); SpineAnimator animator = EditorHelper.GetLastInspectedSpineAnimator(); if (animator != null) { string[] animationNames = animator.GetAnimationNames(); int currentIndex = -1; for (int i = 0; i < animationNames.Length; i++) { if (animationNames[i] == animationIdProperty.stringValue) { currentIndex = i; break; } } int index = EditorGUILayout.Popup("Animation", currentIndex == -1 ? 0 : currentIndex, animationNames); if (currentIndex != index) { animationIdProperty.stringValue = animationNames[index]; serializedObject.ApplyModifiedProperties(); if (Application.isPlaying) { ((SpineAnimatorStateBehaviour)target).ForceUpdate(); } } } else { GUI.enabled = false; EditorGUILayout.PropertyField(animationIdProperty); GUI.enabled = true; } }