複製的感覺挺有用就保存下來 using System.Collections;using System.Collections.Generic;using UnityEngine; public class CURRENT : MonoBehaviour { private List<int> co ...
複製的感覺挺有用就保存下來
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CURRENT : MonoBehaviour {
private List<int> content = new List<int>
{
5,
6,
7,
13,
8,
9,
10,
11,
12,
14
};
//列表當前ID
private int currentID = 0;
//下一個ID
public int NextID
{
get
{
currentID++;
print("數:" + currentID);
currentID = currentID % content.Count;
print("餘數:" + currentID);
return currentID;
}
}
//上一個ID
public int LastID
{
get
{
currentID--;
if (currentID < 0) currentID = content.Count - 1;
print("數:" + currentID);
currentID = currentID % content.Count;
print("餘數:" + currentID);
return currentID;
}
}
private void Update()
{
if (Input.GetMouseButtonDown(0))
{
print(content[NextID]);
}
if (Input.GetMouseButtonDown(1))
{
print(content[LastID]);
}
}
}