I am instantiating a GO at some point during runtime, it has a button attached. The buttons onclick function is determined when it is instantiated. Should I be able to save what this onclick does. I have selected m_OnClick on the prefab ES3, but that doesnt seem to save what the onclick does?
The entire code is basically
Code: Select all
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
GameObject newButton = Instantiate(but, spawnInfo.transform.position, Quaternion.identity, spawnInfo.transform.parent);
newButton.GetComponent<Button>().onClick.AddListener(() => { Debug.Log("Button press"); });
}
}