2024-12-12 17:06:08 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2024-12-12 17:51:28 +08:00
|
|
|
|
/// <20><><EFBFBD>嶯<EFBFBD><E5B6AF><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD><EFBFBD>͡<EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
public enum MyLoopType
|
|
|
|
|
{
|
|
|
|
|
Once, // <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
|
|
|
|
Count, // <20><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
Forever // <20><><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD>嶯<EFBFBD><E5B6AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD><EFBFBD>͡<EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
public enum GroupLoopType
|
|
|
|
|
{
|
|
|
|
|
Once, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD>һ<EFBFBD>κ<EFBFBD><CEBA><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
Count, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
Forever // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><>ʾһ<CABE><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD><EFBFBD>һϵ<D2BB>о<EFBFBD><D0BE>顢ÿ֡<C3BF><D6A1><EFBFBD><EFBFBD>ʾʱ<CABE><CAB1><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD><EFBFBD>͡<EFBFBD>
|
2024-12-12 17:06:08 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
[System.Serializable]
|
|
|
|
|
public class AnimationSequence
|
|
|
|
|
{
|
|
|
|
|
[Tooltip("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>еľ<D0B5><C4BE><EFBFBD><EFBFBD>б<EFBFBD>")]
|
|
|
|
|
public List<Sprite> sprites = new List<Sprite>();
|
|
|
|
|
|
|
|
|
|
[Tooltip("ÿһ֡<D2BB><D6A1>ʱ<EFBFBD>䣬<EFBFBD><E4A3AC>λ<EFBFBD><CEBB>")]
|
|
|
|
|
public float frameTime = 0.1f; // ÿ֡<C3BF>ij<EFBFBD><C4B3><EFBFBD>ʱ<EFBFBD>䣨<EFBFBD>룩
|
2024-12-12 17:51:28 +08:00
|
|
|
|
|
|
|
|
|
[Tooltip("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>")]
|
|
|
|
|
public MyLoopType loopType = MyLoopType.Forever; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
[Tooltip("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> LoopType Ϊ Count ʱ<><CAB1>Ч<EFBFBD><D0A7>")]
|
|
|
|
|
public int loopCount = 1; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2024-12-12 17:06:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2024-12-12 17:51:28 +08:00
|
|
|
|
/// <20><><EFBFBD>ƾ<EFBFBD><C6BE>鶯<EFBFBD><E9B6AF><EFBFBD><EFBFBD><EFBFBD>ŵ<EFBFBD><C5B5>֧࣬<E0A3AC><D6A7><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊÿ<CEAA><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD><EFBFBD>ͺ<EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2024-12-12 17:06:08 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
public class SpriteAnimator : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
[Header("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>")]
|
|
|
|
|
[Tooltip("<22><><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>")]
|
|
|
|
|
public List<AnimationSequence> animationSequences = new List<AnimationSequence>();
|
|
|
|
|
|
|
|
|
|
[Header("SpriteRenderer<65><72><EFBFBD><EFBFBD>")]
|
|
|
|
|
[Tooltip("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>SpriteRenderer")]
|
|
|
|
|
public SpriteRenderer spriteRenderer;
|
|
|
|
|
|
2024-12-12 17:51:28 +08:00
|
|
|
|
[Header("<22><>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>")]
|
|
|
|
|
[Tooltip("ѡ<><EFBFBD><F1B6AFBB><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>")]
|
|
|
|
|
public GroupLoopType groupLoopType = GroupLoopType.Forever;
|
2024-12-12 17:06:08 +08:00
|
|
|
|
|
2024-12-12 17:51:28 +08:00
|
|
|
|
[Tooltip("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> GroupLoopType Ϊ Count ʱ<><CAB1>Ч<EFBFBD><D0A7>")]
|
|
|
|
|
public int groupLoopCount = 1;
|
2024-12-12 17:06:08 +08:00
|
|
|
|
|
|
|
|
|
// <20>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
private Dictionary<int, AnimationSequence> animationDictionary = new Dictionary<int, AnimationSequence>();
|
|
|
|
|
private AnimationSequence currentAnimation;
|
|
|
|
|
private int currentFrameIndex = 0;
|
|
|
|
|
private float frameTimer = 0f;
|
|
|
|
|
private bool isPlaying = true;
|
2024-12-12 17:51:28 +08:00
|
|
|
|
private int currentAnimationIndex = 0; // <20><>ǰ<EFBFBD><C7B0><EFBFBD>ŵĶ<C5B5><C4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
private int currentGroupLoopIteration = 0; // <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
private int currentSequenceLoopIteration = 0; // <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2024-12-12 17:06:08 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>档
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void Awake()
|
|
|
|
|
{
|
|
|
|
|
if (animationSequences == null || animationSequences.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
Debug.LogError("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>Ϊ<EFBFBD>ա<EFBFBD><D5A1><EFBFBD><EFBFBD><EFBFBD> Inspector <20><><EFBFBD><EFBFBD><EFBFBD>Ӷ<EFBFBD><D3B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD>");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < animationSequences.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
if (!animationDictionary.ContainsKey(i))
|
|
|
|
|
{
|
|
|
|
|
animationDictionary.Add(i, animationSequences[i]);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Debug.LogWarning($"<22><><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><D8B8>Ķ<EFBFBD><C4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> {i}<7D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><D8B8>");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SetAnimation(currentAnimationIndex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20>ڿ<EFBFBD>ʼʱ<CABC><CAB1><EFBFBD>г<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void Start()
|
|
|
|
|
{
|
|
|
|
|
if (spriteRenderer == null)
|
|
|
|
|
{
|
|
|
|
|
Debug.LogError("SpriteRenderer 'spriteRenderer' Ϊ<>ա<EFBFBD><D5A1><EFBFBD><EFBFBD><EFBFBD> Inspector <20>з<EFBFBD><D0B7><EFBFBD> SpriteRenderer<65><72>");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (currentAnimation != null && currentAnimation.sprites.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
frameTimer = currentAnimation.frameTime;
|
|
|
|
|
spriteRenderer.sprite = currentAnimation.sprites[currentFrameIndex];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Debug.LogError("<22><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>ջ<D5BB><F2B2BBB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>顣");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// ÿ֡<C3BF><D6A1><EFBFBD>¶<EFBFBD><C2B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>š<EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void Update()
|
|
|
|
|
{
|
|
|
|
|
if (!isPlaying || currentAnimation == null || currentAnimation.sprites.Count == 0)
|
|
|
|
|
return;
|
|
|
|
|
|
2024-12-12 17:51:28 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD>֡<EFBFBD><D6A1>ʱ<EFBFBD><CAB1>
|
2024-12-12 17:06:08 +08:00
|
|
|
|
frameTimer -= Time.deltaTime;
|
|
|
|
|
|
|
|
|
|
if (frameTimer <= 0f)
|
|
|
|
|
{
|
|
|
|
|
AdvanceFrame();
|
2024-12-12 17:51:28 +08:00
|
|
|
|
|
|
|
|
|
// <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
MyLoopType currentLoopType = currentAnimation.loopType;
|
|
|
|
|
|
|
|
|
|
switch (currentLoopType)
|
|
|
|
|
{
|
|
|
|
|
case MyLoopType.Once:
|
|
|
|
|
if (currentFrameIndex == currentAnimation.sprites.Count - 1)
|
|
|
|
|
{
|
|
|
|
|
MoveToNextSequence();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case MyLoopType.Count:
|
|
|
|
|
if (currentFrameIndex == currentAnimation.sprites.Count - 1)
|
|
|
|
|
{
|
|
|
|
|
currentSequenceLoopIteration++;
|
|
|
|
|
if (currentSequenceLoopIteration >= currentAnimation.loopCount)
|
|
|
|
|
{
|
|
|
|
|
MoveToNextSequence();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ResetCurrentSequence();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case MyLoopType.Forever:
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E2B4A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD>
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-12 17:06:08 +08:00
|
|
|
|
frameTimer = currentAnimation.frameTime;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD>õ<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD>ŵĶ<C5B5><C4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="index"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
|
|
|
|
|
public void SetAnimation(int index)
|
|
|
|
|
{
|
|
|
|
|
if (animationDictionary.TryGetValue(index, out AnimationSequence selectedAnimation))
|
|
|
|
|
{
|
|
|
|
|
currentAnimation = selectedAnimation;
|
|
|
|
|
currentFrameIndex = 0;
|
|
|
|
|
frameTimer = currentAnimation.frameTime;
|
2024-12-12 17:51:28 +08:00
|
|
|
|
currentSequenceLoopIteration = 0;
|
2024-12-12 17:06:08 +08:00
|
|
|
|
|
|
|
|
|
if (currentAnimation.sprites.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
spriteRenderer.sprite = currentAnimation.sprites[currentFrameIndex];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Debug.LogWarning($"ѡ<>еĶ<D0B5><C4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> {index} û<>а<EFBFBD><D0B0><EFBFBD><EFBFBD>κξ<CEBA><CEBE>顣");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Debug.LogError($"SetAnimation: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> {index} <20><> animationDictionary <20><>δ<EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD>");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD>IJ<EFBFBD><C4B2>ź<EFBFBD><C5BA><EFBFBD>ͣ<EFBFBD><CDA3>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="play">true: <20><><EFBFBD>Ŷ<EFBFBD><C5B6><EFBFBD>, false: <20><>ͣ<EFBFBD><CDA3><EFBFBD><EFBFBD></param>
|
|
|
|
|
public void PlayPauseAnimation(bool play)
|
|
|
|
|
{
|
|
|
|
|
isPlaying = play;
|
|
|
|
|
if (isPlaying && currentAnimation != null && currentAnimation.sprites.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
// ȷ<><C8B7><EFBFBD><EFBFBD>ǰ֡<C7B0><D6A1>ʾ<EFBFBD><CABE>ȷ
|
|
|
|
|
spriteRenderer.sprite = currentAnimation.sprites[currentFrameIndex];
|
|
|
|
|
frameTimer = currentAnimation.frameTime;
|
2024-12-12 17:51:28 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> currentSequenceLoopIteration<6F><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӱ<EFBFBD><D3B0>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2024-12-12 17:06:08 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2024-12-12 17:51:28 +08:00
|
|
|
|
/// ǰ<><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ֡<D2BB><D6A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>SpriteRenderer<65>ľ<EFBFBD><C4BE>顣
|
2024-12-12 17:06:08 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
private void AdvanceFrame()
|
|
|
|
|
{
|
2024-12-12 17:51:28 +08:00
|
|
|
|
if (currentAnimation.sprites.Count == 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
currentFrameIndex++;
|
|
|
|
|
|
|
|
|
|
if (currentFrameIndex >= currentAnimation.sprites.Count)
|
2024-12-12 17:06:08 +08:00
|
|
|
|
{
|
2024-12-12 17:51:28 +08:00
|
|
|
|
currentFrameIndex = currentAnimation.sprites.Count - 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
spriteRenderer.sprite = currentAnimation.sprites[currentFrameIndex];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD>õ<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>еIJ<D0B5><C4B2><EFBFBD>״̬<D7B4><CCAC><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void ResetCurrentSequence()
|
|
|
|
|
{
|
|
|
|
|
currentFrameIndex = 0;
|
|
|
|
|
frameTimer = currentAnimation.frameTime;
|
|
|
|
|
spriteRenderer.sprite = currentAnimation.sprites[currentFrameIndex];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD><EFBFBD>;<EFBFBD><CDBE><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD><D9B6><EFBFBD><EFBFBD>顣
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void MoveToNextSequence()
|
|
|
|
|
{
|
|
|
|
|
currentAnimationIndex++;
|
|
|
|
|
|
|
|
|
|
if (currentAnimationIndex >= animationSequences.Count)
|
|
|
|
|
{
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>鶯<EFBFBD><E9B6AF><EFBFBD><EFBFBD>
|
|
|
|
|
currentAnimationIndex = 0;
|
|
|
|
|
currentGroupLoopIteration++;
|
|
|
|
|
|
|
|
|
|
switch (groupLoopType)
|
|
|
|
|
{
|
|
|
|
|
case GroupLoopType.Once:
|
|
|
|
|
isPlaying = false;
|
|
|
|
|
Destroy(gameObject); // <20><><EFBFBD>ٶ<EFBFBD><D9B6><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
case GroupLoopType.Count:
|
|
|
|
|
if (currentGroupLoopIteration >= groupLoopCount)
|
2024-12-12 17:06:08 +08:00
|
|
|
|
{
|
2024-12-12 17:51:28 +08:00
|
|
|
|
isPlaying = false;
|
|
|
|
|
Destroy(gameObject); // <20><><EFBFBD>ٶ<EFBFBD><D9B6><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
return;
|
2024-12-12 17:06:08 +08:00
|
|
|
|
}
|
2024-12-12 17:51:28 +08:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GroupLoopType.Forever:
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
break;
|
|
|
|
|
}
|
2024-12-12 17:06:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-12-12 17:51:28 +08:00
|
|
|
|
SetAnimation(currentAnimationIndex);
|
2024-12-12 17:06:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD><D9B6><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>档
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void OnDestroy()
|
|
|
|
|
{
|
|
|
|
|
animationDictionary.Clear();
|
|
|
|
|
animationSequences = null;
|
|
|
|
|
currentAnimation = null;
|
|
|
|
|
}
|
|
|
|
|
}
|