VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > Python基础教程 >
  • C#教程之unity list循环

复制的感觉挺有用就保存下来

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]);
}

}


}

 
分类: Unity3d


相关教程