- 最后登录
- 2019-12-2
- 注册时间
- 2012-8-25
- 阅读权限
- 90
- 积分
- 34660
- 纳金币
- 38266
- 精华
- 111
|
using unityEngine;
using System.Collections;
using System.Collections.Generic;
public class list : MonoBehaviour {
List<string> ListName = new List<string>();
void Start () {
ListName.Add ("a1");
ListName.Add ("b2");
ListName.Add ("c3");
ListName.Add ("d4");
ListName.Add ("e5");
ListName.Add ("f6");
ListName = RandName (ListName);
foreach (string name in ListName) {
print(name);
}
}
//suijishuzu
List<string>RandName(List<string>OldName)
{
List<string> NListName=new List<string>();
while (NListName.Count<OldName.Count) {
int i=Random.Range(0,OldName.Count);
if(!NListName.Contains(OldName[i]))
NListName.Add(OldName[i]);
}
return NListName;
}
} |
|