# GumService (GumUI)

## Introduction

GumService provides access to common Gum objects and methods. It simplifies initialization, updating, and drawing the Gum system. Typically the Default instance is used in games, and a property can be created at class scope to reduce boilerplate code.

Many documentation pages create a property named GumUI as shown in the following code:

```csharp
GumService GumUI => GumService.Default;
```

## Initialize

`Initialize` is called in all Gum projects. This method performs the following:

* Internally creates all Gum systems
* Optionally loads a Gum project (.gumx)
* Specifies the version of code-only visuals to use

`Initialize` is typically called in the Game class or other top-level class depending on your current platform.

### Loading a Gum Project (.gumx)

To load a Gum project, the following code can be used:

```csharp
// Initialize
GumUI.Initialize(this, "GumProject/GumProject.gumx");
```

This code assumes that the Gum project is located in the following path relative to your .csproj file:

```
Content/GumProject/GumProject.gumx
```

If the Gum project is located outside of the Content folder, it can be loaded using a number of techniques:

1. Prefix the path with "../". For example the following code can be used to load a Gum project located in a resources folder:

   ```csharp
   // Initialize
   GumUI.Initialize(this, "../resources/GumProject/GumProject.gumx");
   ```
2. Set FileManager.RelativeDirectory prior to loading:

   ```csharp
   // Initialize
   FileManager.RelativeDirectory = "resources/";
   GumUI.Initialize(this, "GumProject/GumProject.gumx");
   ```
3. Set an absolute path. Be careful specifying an absolute path as this may prevent your project from running on other machines.

   ```csharp
   // Initialize
   GumUI.Initialize(this, "c:/Gum/GumProject.gumx");
   ```


---

# Agent Instructions: 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:

```
GET https://docs.flatredball.com/gum/code/gum-code-reference/gumservice-gumui.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
