2024-11-15 15:21:16 +08:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[System.Serializable]
|
|
|
|
|
public class Mysprites
|
|
|
|
|
{
|
|
|
|
|
public List<Sprite> mysprites = new List<Sprite>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class SpriteAniationpro : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
[Header("֡<><D6A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ")]
|
|
|
|
|
public List<Mysprites> sprites;
|
|
|
|
|
[Header("<22><><EFBFBD>Ŷ<EFBFBD><C5B6><EFBFBD><EFBFBD><EFBFBD>image")]
|
|
|
|
|
public Image image;
|
|
|
|
|
[Header("֡ʱ<D6A1><CAB1>,<2C><>λ<EFBFBD><CEBB><EFBFBD>룬Ĭ<EBA3AC><C4AC>100")]
|
|
|
|
|
public float Aintime=100f;
|
|
|
|
|
[Header("<22><><EFBFBD>Ŷ<EFBFBD><C5B6><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD>")]
|
|
|
|
|
public int myspritesIndex=0;
|
2024-11-15 15:24:50 +08:00
|
|
|
|
|
|
|
|
|
|
2024-11-15 15:21:16 +08:00
|
|
|
|
private int index=0;
|
2024-11-15 22:44:04 +08:00
|
|
|
|
private Mysprites myspritesAni;
|
2024-11-15 15:21:16 +08:00
|
|
|
|
// Start is called before the first frame update
|
2024-11-15 22:44:04 +08:00
|
|
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
|
{
|
|
|
|
|
SetAni(myspritesIndex);
|
|
|
|
|
}
|
2024-11-15 15:21:16 +08:00
|
|
|
|
void Start()
|
|
|
|
|
{
|
|
|
|
|
if (image==null)
|
|
|
|
|
{
|
|
|
|
|
Debug.LogError("image is null");
|
|
|
|
|
}
|
|
|
|
|
if (sprites.Count==0)
|
|
|
|
|
{
|
|
|
|
|
Debug.LogError("sprites is not");
|
2024-11-15 22:44:04 +08:00
|
|
|
|
}
|
2024-11-15 15:24:50 +08:00
|
|
|
|
|
2024-11-15 15:21:16 +08:00
|
|
|
|
InvokeRepeating("ainstart", 0f,(Aintime / 1000));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void SetAni(int Index)
|
2024-11-15 22:44:04 +08:00
|
|
|
|
{
|
2024-11-18 12:03:32 +08:00
|
|
|
|
//Debug.Log("SetAni"+ Index);
|
2024-11-15 22:44:04 +08:00
|
|
|
|
myspritesAni = sprites[Index];
|
2024-11-15 15:21:16 +08:00
|
|
|
|
index = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ainstart()
|
2024-11-15 22:44:04 +08:00
|
|
|
|
{
|
|
|
|
|
image.overrideSprite = myspritesAni.mysprites[index];
|
2024-11-15 15:21:16 +08:00
|
|
|
|
index++;
|
2024-11-15 22:44:04 +08:00
|
|
|
|
if (index > myspritesAni.mysprites.Count - 1)
|
2024-11-15 15:21:16 +08:00
|
|
|
|
{
|
|
|
|
|
index = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnDestroy()
|
|
|
|
|
{
|
|
|
|
|
sprites = null;
|
2024-11-15 22:44:04 +08:00
|
|
|
|
myspritesAni = null;
|
2024-11-15 15:21:16 +08:00
|
|
|
|
}
|
|
|
|
|
}
|