【发布时间】:2018-03-16 09:44:30
【问题描述】:
在开始时,对象将指向它的链接添加到列表中。然后当我点击这个对象时,我需要获取这个对象的索引引用。怎么做? 我需要的小例子:
public static List<GameObject> myObjects = new List<GameObject> ();
public GameObject ObjectA; //this is prefab
void Start(){
for (int i = 0; i < 10; i++) {
GameObject ObjectACopy = Instantiate (ObjectA);
myObjects.Add (ObjectACopy);
}
}
ObjectA 脚本:
void OnMouseDown(){
Debug.Log(//Here i need to return index of this clicked object from the list);
}
【问题讨论】:
-
有什么代码要分享吗?
标签: c# list unity3d gameobject