E_ElecCompetition/Electrical_inspectionCompet.../Assets/Script/Tool objects/biaomian_change.cs

52 lines
966 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class biaomian_change : MonoBehaviour
{
public int index;
public Image image;
public Sprite[] sprites;
public GameObject up;
public GameObject down;
// Start is called before the first frame update
void Start()
{
EventTriggerListener.Get(up).onClick += g => { spriteup(); };
EventTriggerListener.Get(down).onClick += g => { spritedown(); };
}
// Update is called once per frame
void Update()
{
}
public void spriteup()
{
index += 1;
if (index > sprites.Length) {
index = 0;
}
image.sprite = sprites[index];
}
public void spritedown()
{
index -= 1;
if (index < 0)
{
index = sprites.Length-1;
}
image.sprite = sprites[index];
}
}