Need help creating a pause menu that persists between scenes

I’m having trouble making a working pause menu that can be loaded on any scene. To do that, I’ve made a prefab that gets loaded on an initial scene, and all of the objects inside of it are subject to DontDestroyOnLoad, thus persisting between scenes. However, when I tried to use these menus, more specifically, an inventory menu, the scrollbar doesn’t work, and I can’t scroll through the list. I suspect this is due to some issues with the EventSystem.

This is the prefab (the image components are just there to fill the content):

7097707--845680--upload_2021-5-1_17-39-12.png

This is the scene being loaded:

7097707--845686--upload_2021-5-1_17-40-20.png

Upon running, this is the result:

7097707--845689--upload_2021-5-1_17-41-46.png

7097707--845692--upload_2021-5-1_17-42-13.png

Clicking and dragging the scrollbar does nothing, and using the scrollwheel does nothing either. I have tried to move the EventSystem around - I put it in the prefab whilst deleting it from the original scene, and I tried having it in the scene with none in the prefab as well (this scenario here). Any way to fix this?

Did you try having an event system in the menu prefab?

I did, it was one of the two ways I tried this. I tried having an EventSystem in the scene, and none in the prefab, and vice versa, with the EventSystem in the prefab, and none in the scene. Having both has Unity complain that there shouldn’t be two EventSystems upon execution.

I guess you’ll have to try it with a prefab containing only a default scroll view and see if the issue is there from the start or if you set something wrong somewhere.

I tried creating a separate prefab, just for the pause menu, and loaded it the same way as the other objects. After a slight change in the script so it would load both prefabs (otherwise it would only load one of them), seems like having the prefabs separate works like a charm. The inventory scroll works, and it persists between scenes!

With the issue now resolved, I’ll just mark this thread as resolved. I suspect the problem wasn’t due to the EventSystem after all, but probably due to the way I had the canvas set up.

1 Like