Prefab a 2D UI?

Hi Unity people,

I’ve done some digging and am still confused…

I want to effectively prefab my Pause Screen UI across a number of scenes to ensure consistency and optimise project efficiency. Basically, when the player pauses, a semi-transparent white image should appear with three buttons (play, restart and exit) with the appropriate “on click” functions.

Is it possible to prefab the Pause Screen/menu UI? If so, how do you go about doing this?

Thanks in advance :slight_smile:

Of course you can, any of the gameobjects in the hierarchy can be converted into a prefab to instantiate it later when you want.

The simplest way to do this is select your menu gameobject (if it’s inside a canvas select the canvas, if not just the ui elements you want to reuse) and drag them into your project view.

Then, when you want to instantiate it in another screen you can do use [this] (Unity - Manual: Instantiating Prefabs at run time) in any of your scripts to add it to your hierarchy again and use it’s functionality.

Hope it helps.

I had a canvas (created automatically a la Unity) created but can delete and extract just the actual elements,

Any idea as to why its cloning in the hierarchy but not showing up in the scene/game view?

Thanks so much"!