Button onclick save
Posted: Tue Feb 04, 2025 4:27 pm
Hi, Sorry to need to contact again so soon. However, I am having an issue that I cant find anything in the docs or forums relate to.
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
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"); });
}
}