Game Manager Dont destroy onload

Hi
I have a loader that pull game manager prefab script once,
for now how I can assign a function from game manager to a UI button from inspector while its not accessible before the pull?
-thanks

Short answer is you can’t. You can however do it programmatically as long as you have access to that Button Object when you Instantiate the GameManager

// First you need to get a hold of the button with
public Button button;  // then drag the button using the editor to this script
// or find somewhere to get  a hold of the button
Button myButton = GetComponent<Button>();
  // this won't work unless button is a component of this script
// but you get the idea.. you'll need to find the button using Unity functions

GameManager myObject = Instantiate(GameMangerPrefab) as GameManger;

myButton.onClick.AddListener(delegate {myObject.FunctionYouNeed();});

er… it makes a lot more sense for the gamemanager to be the thing which is persistent across many scenes which is what I think the OP is getting at.

Assuming it’s following a singleton pattern you can use GetComponentOfType() to get the reference to the first (and one would hope only) gamemanager in the scene and then do the programmatic assignment to the onclick function.

thanks