void Update ()
{
frameNumber = frames.Length;//重点
if(!oneTime)
{
myTime += Time.deltaTime;//时间的累加
myIndex = (int)(myTime * (frameNumber - 1));//重点复习~~
index = myIndex % frameNumber;
}
renderer.material.mainTexture = frames[index];
if (direction)
renderer.material.mainTextureScale = new Vector2(1.0f, 1);
else
renderer.material.mainTextureScale = new Vector2(-1.0f, 1);
if (index == frameNumber - 1 && destroy)
Destroy(gameObject);
if (lastFrameNo != 0)
{
if (index == lastFrameNo - 1)
oneTime = true;
}
时间: 2024-11-03 22:37:49