I don't know actually what to search on google so I directly get here and I am sorry about that . My problem is that I have Instantiate()
objects like this
public void InstantiateObject(){
//the list has 5 objects in it .
for (int i = 0; i < list.Count; i++)
{
GameObject o = Instantiate(lobby_object) as GameObject;
o.transform.SetParent(pos_lobby_object);
o.transform.localScale = Vector3.one;
o.transform.name = "spr_boards " + lobby_object_no;
o.transform.localPosition = new Vector3(0, 0, 0);
NGUITools.SetActive(o, true);
}
}
The output of that would be
spr_boards 1
spr_boards 2
spr_boards 3
spr_boards 4
spr_boards 5
I have a click event by the way on another script
public void InstantiateTheObject(){
fromAnotherScript.InstantiateObject();
}
Then drag this InstantiateTheObject
to the button on the inspector
Now I want to click one of this object and return what number are they but I don't know how to do it .
EDIT:
More information
If i clicked the Instantiated spr_board 1
for example this must log for example a "this is object 1";
then if i click spr_board 2
for example this must log for example a "this is object 2`;
I tried this
public void InstantiateTheObject(){
Debug.Log("objects number is : " + lobby_object_no);
fromAnotherScript.InstantiateObject();
}
but the problem is that it always get the last value of my last . It's not depending on what I click on the instantiated object.