How can I stop the game background from disappearing?,Instantiating Objects During Run Time Makes The Objects Disappear

I’m creating a pause menu for my game, and I’m using my controller script on my camera to instantiate a prefab consisting of an image back panel (just a white box - not a UI panel) , text saying “PAUSED” and 2 buttons - respectively “quit” and “resume”.

However, when you press escape / press the PAUSE button it the corner, only the text appears. If you go into the scene view and zoom out, the backing is there, but if you zoom in it disappears (at the same time as gizmos and icons and such, I don’t know if it is relevant). It is not visible in the game view at all. I tried instantiating the back piece separately. Didn’t work. If I import the prefab not during run time it always remains visible, so I could just activate/deactivate it but I don’t want to have to place and assign the prefab in all of the 20+ levels. Instantiating objects as part of the game (which I made while making the game play) still work. I genuinely don’t have a clue as to what is happening.

.

EDIT: I don’t know if this changes anything, but I have Unity 2018 personal

Firstly, use UI, it sucks, however it can be pretty powerful. As I don’t know what type of objects you are creating, but it sounds like this panel is funky. Are you using a plane? A cube? Special material properties?

What happened was I instantiated the object to the transform position of the camera (including the z). I don’t know why it went weird in scene view, but it would make sense if it didn’t appear in the game view (ui text doesn’t project using the camera for some reason in 2D, the canvas just bypasses it, for an explanation on that behalf). I just instantiated it only using the camera’s x and y properties, and that worked.