Hello Forum,
I’m trying to make a menu that is built at runtime.
for (int i = 0; i < bd.ItemCount(); i++) {
buttons.Add((GameObject)Instantiate(button));
buttons*.transform.SetParent(transform, false);*
_ buttons*.transform.GetChild(0).GetComponent().text = bd.GetNameById((byte)i);*_
_ Vector3 position = buttons*.GetComponent().position;
position.y -= 40 * i;
buttons.GetComponent().position = position;*_
_ buttons*.GetComponent().onClick.AddListener(() => {
builder.SelectItem(buttons.transform.GetChild(0).GetComponent().text);
});
}*
You can ignore the first part.
I can imagine why this isn’t working but I have no better idea.
The problem is that the call to the method is when the i does not exist anymore.
How can I know which button called the method?
Thanks!_
The bug is not fixed yet. (January 2016, version 5.3).
– SchreiberHi All I have also looking for the code. First time i have run the code. It works perfect. But after that i have try to run the above code. It shows the error... NullReferenceException: Object reference not set to an instance of an object It does not works.. How can i solve it......
– Deprecative