欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

unity list循环

程序员文章站 2022-05-18 23:01:28
复制的感觉挺有用就保存下来 using System.Collections;using System.Collections.Generic;using UnityEngine; public class CURRENT : MonoBehaviour { private List 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]);
}

}


}