powerfun-unity/Assets/Scenes/Ride/Scripts/SpirteRenderScript.cs

48 lines
1.0 KiB
C#
Raw Normal View History

2021-04-23 19:28:35 +08:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace Assets.Scenes.Ride.Scripts
{
public class SpirteRenderScript:MonoBehaviour
{
List<Sprite> sprites;
Image image;
private void Start()
{
sprites = new List<Sprite>();
for (int i = 1; i < 61; i++)
{
sprites.Add(Resources.Load<Sprite>($"Images/Ride/wave/wave{i.ToString("0000")}"));
}
image = transform.GetComponent<Image>();
2021-04-28 15:37:18 +08:00
2021-04-23 19:28:35 +08:00
}
2021-04-28 15:37:18 +08:00
2021-04-23 19:28:35 +08:00
int index = 0;
float time = 0;
2021-04-28 15:37:18 +08:00
float totaltime = 0;
2021-04-23 19:28:35 +08:00
void Update()
{
time += Time.deltaTime;
2021-04-28 15:37:18 +08:00
totaltime += Time.deltaTime;
2021-04-23 19:28:35 +08:00
if (time < 0.03)
{
return;
}
time = 0;
2021-04-28 15:37:18 +08:00
image.sprite = sprites[index];
index++;
2021-04-23 19:28:35 +08:00
if (index % 59 == 0)
{
index = 0;
}
2021-04-28 15:37:18 +08:00
2021-04-23 19:28:35 +08:00
}
}
}