コード例 #1
0
ファイル: MapData.cs プロジェクト: zhaoyang90/WzComparerR2
 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>();
     }
 }
コード例 #4
0
                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);
                            }
                        }
                    }
                }
コード例 #5
0
 public void StopAll()
 {
     for (int i = 0; i < _renderer._animationSets.Length; i++)
     {
         SpineAnimator childAnimator = _renderer._animationSets[i]._animatior;
         childAnimator.StopAll();
     }
 }
コード例 #6
0
 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);
     }
 }
コード例 #7
0
 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);
     }
 }
コード例 #8
0
 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);
     }
 }
コード例 #9
0
 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);
     }
 }
コード例 #10
0
 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);
     }
 }
コード例 #11
0
                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);
                }
コード例 #12
0
                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);
                }
コード例 #13
0
                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);
                }
コード例 #14
0
                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);
                }
コード例 #15
0
                        private static void OnSelectionChanged()
                        {
                            if (Selection.activeGameObject != null)
                            {
                                SpineAnimator animator = Selection.activeGameObject.GetComponent <SpineAnimator>();

                                if (animator != null)
                                {
                                    _animator = animator;
                                }
                            }
                        }
コード例 #16
0
                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);
                }
コード例 #17
0
                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);
                }
コード例 #18
0
                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);
                }
コード例 #19
0
 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);
 }
コード例 #20
0
                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());
                        }
                    }
                }
コード例 #21
0
        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();
            }
        }
コード例 #22
0
                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);
                }
コード例 #23
0
                    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;
                        }
                    }