> For the complete documentation index, see [llms.txt](https://docs.flatredball.com/flatredball/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flatredball.com/flatredball/gum/how-to-add-components-to-layers.md).

# Adding Components to Layers

### Introduction

Gum Screens and Components can be added to Layers in Glue. This page discusses some common scenarios for layering Gum objects in Glue. For information on moving Gum objects to layers in code, see the [MoveToFrbLayer page](/flatredball/api/gum-runtime-api/gum-wireframe-graphicaluielement/movetofrblayer.md).

### Adding an entire Screen to a Layer in Glue

Entire Gum Screens can be added to a Glue Layer. The following steps assume:

* A Glue Screen called GameScreen
* A Gum screen called MainScreen
* The Gum screen added as a file under the Glue screen

![LayeredGumScreen1.PNG](/files/82UraLaRKXIeQuGnjOvh) The first step is to add the entire Gum screen as an object in the Glue screen:

1. Right-click on Objects
2. Select "Add Object"
3. Select the "From File" option
4. Select the MainScreen.gusx file
5. Select "this" option (the first option in the drop-down
6. Enter the name GumScreenInstance
7. Click OK

![AddingGumScreenInstanceToGlue.gif](/files/LiRQWoQYWDosNkZjKDwq) Now the Screen can be added to the Glue Layer:

1. Right-click on Objects
2. Select "Add Object"
3. Make sure "FlatRedBall or Custom Type" is selected
4. Select Layer
5. Click OK
6. Drag+drop the GumScreenInstance onto the newly-created Layer

![AddGumScreenToLayer.gif](/files/Danj1j3iGX6CbDVV7imL) Now the entire GumScreenInstance (that is the entire MainScreen from Gum) will be drawn on LayerInstance.

### Adding an Entire Gum Screen to a Layer in Code

Gum screens can also be added to Glue Layers in code. For this example we'll assume your project already has:

* A Glue screen (GameScreen)
* A Gum screen in the Glue screen (GameScreenGum)
* A Layer (LayerInstance)

To add the Gum screen to the Layer in code:

1. Open the project in Visual Studio
2. Open **GameScreen.cs**
3. Add the following code to CustomInitialize:

```lang:c#
void CustomInitialize()
{
    GameScreenGum.MoveToFrbLayer(LayerInstance, LayerInstanceGum);
}
```

Note that the call requires two layers: LayerInstance and LayerInstanceGum. This is required because the GameScreenGum is a Gum object, so ultimately it must exist on a Gum layer. However, Glue simplifies this process by creating a Gum layer for every FlatRedBall layer automatically, so you do not have to worry about creating the Gum layer yourself if you added a Layer through Glue.

### Splitting objects on multiple Layers

Individual objects within a Gum screen can be added to a Layer. To add an object to a layer:

1. Verify that your Glue screen has a Gum screen.
2. Right-click on the Objects folder
3. Add a new Layer
4. Right-click on the Objects folder
5. Select "From File"
6. Select the Gum screen (.gusx)
7. Select the object within the Gum screen which you'd like to move to a new layer
8. Drag+drop the object onto the Glue layer

![AddGumInstanceToLayer.gif](/files/jhv6PCAH0TlxLMVGN9iw)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.flatredball.com/flatredball/gum/how-to-add-components-to-layers.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
