# Prefab structure

Base prefab is UI. It will hold all core UICanvasControllers runtime (in prefab there shouldn't be any canvases):

<figure><img src="https://1613353771-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fygjewtla1W7kzTTIpGWq%2Fuploads%2F9Odq6JA4z9k8Gk4Ga9bM%2Fimage.png?alt=media&#x26;token=2646c9a2-6542-4e41-9338-0230f41897b6" alt=""><figcaption><p>UI object when game running</p></figcaption></figure>

### How to add UI prefab to scene

You need to replace it under SceneUI object in hierarchy (under \_x\_Scope of scene with name x):

<figure><img src="https://1613353771-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fygjewtla1W7kzTTIpGWq%2Fuploads%2F9LgZdYgfiw0o8tPLuEA1%2Fimage.png?alt=media&#x26;token=fca9703c-233d-464a-9449-78ef85ec5be5" alt=""><figcaption></figcaption></figure>

If you want to activate your UI object on scene start. Select SceneUI object and set Canvas To Activate link to your UI object in scene.

### **MainMenuCanvas**

Is what should be in Menu scene. \
\
You can put in MainMenu more UICanvasController and switch between by MainMenu UICanvasController (for example MenuSettingsCanvas, SkinSelectCanvas and etc).&#x20;

### GameCanvas

GameCanvas is main canvas of core gameplay of your game, here should be core game elements (health bar, joystick and etc).

## How to setup GameCanvas

<figure><img src="https://1613353771-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fygjewtla1W7kzTTIpGWq%2Fuploads%2F15Yo0HJVZNhipQhOj49P%2Fimage.png?alt=media&#x26;token=93eab3aa-cc6a-4ccd-b114-986528ddd607" alt=""><figcaption><p>Path to GameCanvas states</p></figcaption></figure>

So you need to change content of each State (window).

### How to call PauseState by onClick button event

You need to open GameCanvas prefab and then select btn where you want open Pause window from and add to btn onClick event, then drag and drop GameCanvas object to btn event and choose GameCanvas.TogglePause(float) method + set valuse of fade duration (transition).

<figure><img src="https://1613353771-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fygjewtla1W7kzTTIpGWq%2Fuploads%2FmcCPqSkkfnirQEHJhNKl%2Fimage.png?alt=media&#x26;token=f9efbdcc-f98b-4180-8c1f-74d51a4b788f" alt=""><figcaption><p>OnClick event setup from GameCanvas prefab</p></figcaption></figure>
