A shared in-game hud for all scenes/levels
I am building a game in unity which has different levels but all levels require the same HUD functionality (i.e. HUD button pressed, something in the level happens no matter what level is currently running).
So initially I created a UI button and connected its OnClick
event to a game object (a level controller script) in a certain scene. I thought of saving the Canvas
as a prefab and put it in the other scenes/levels as well. This works but the OnClick
connection is lost (as we need an instance and not a prefab) so this requires me for each level to connect all the HUD buttons to the required level controller game object.
Is there a more subtle way to make a shared HUD/Canvas or create a global GameObject which will be used/accessible by all the scenes? Is there a common method for this?
Your answer
![](https://koobas.hobune.stream/wayback/20220612065056im_/https://answers.unity.com/themes/thub/images/avi.jpg)