Please help !
Here is my code
Script1
Public class Test1: Monobehaviour{
Public GameObject buttonprefab;
Public Transform grid;
Public delegate void Functionreturntype();
public void SpawButton(GameObject clone, string buttonname, Functionreturntype)
{
Clone = (GameObject) Instantiate (buttonprefab,grid);
Button button = clone.GetComponets();
Butto .onClick.AddListener(delegate {Function type};});
TextMeshProGUI buttontext = button.GetComponetInChildren();
Buttontext.text = buttonname;
}
}
Scrip2
Public class Test2: Monobehaviour{
Public Test1 test1;
Public GameObject myclone;
Void Start ( ){
Test1.SpawButton(myclone,"opendoor", Opendoor);
}
Void Opendoor(){
Debug.Log("opening") ;
}
}
Everything works fine and I get no error.
The idea is to be able to delete clone button
whenever I want to but the problem is that ‘clone’ from “script 1” never equal to clone of "script 2 " which is weird because I’m unable to delete the clone button whenever I call the function.
I also tested it in inspector no luck.