So I have a prefab which containcs another prefab with a group of buttons. So in one of the buttons I want to attach on the onClick enviroment a gameObject which is in my scene to get its scripts and finally its methods. I can attach just the script but I cannot find the methods of it(They are public). I can’t look into the prefab and at the same time at the game object so that I drag and attach into the onClick button. When I click one the other disappears. Any suggestions?
@anonrika It doesn’t work that way. since you only need the scripts attached to the GameObject and not the Gameobject itself, create a singleton instance of that script you need to use and then you can access its public methods from any other script directly.
@anonrika Prefabs cannot contain references to scene objects , so this is why you are getting the reference removed.
What you can do though, is when you instantiate the object to your scene , find the object containing the function you want to call and pass it as a delegate on the OnClick event of your button like so:
TheButtonYouWant.onClick.AddListener(delegate{TheScriptYouWant.TheFunction({ function parameters}); });