Reuse game objects across different scenes on inspector: button On Click()

So I make a monobehavior containing a function like:
PlaySfx (string soundName){//play the sound }

I create a game object implementing the script, I add an audiosource component to it and use the DontDestroyOnLoad

In the scene this game object is created, I assign it to a button script On Click(), so I can trigger a click sound each time that button is clicked.

If I move to another scene, If I try to set up another button script On Click() to trigger another sound, I can’t because the gameobject isn’t in the scene.

Please, any suggestion on how to do it?

5186483--515348--Captura.PNG

You cant reference objects inbetween scenes using game object inspector. You should do it directly. Instead, make small script what attaches a event handler to the button clikc event internally via code and, when button is clicked, invoke your PlaySfx from that event handler

What about scriptable objects with the functions? They persist along different scenes.
Would you recommend doing it that way?

For scriptable objects theres good article on this here https://unity3d.com/how-to/architect-with-scriptable-objects It requires a little bit more effort, but if you’re accurate enough and good in organizing those objects into meaningfull folders, then it should be good for you