# LoadedOnlyWhenReferenced

### Introduction

LoadedOnlyWhenReferenced is a property which tells Glue to not load a file until it is referenced in code. This is can be used for optionally loaded content - that is, content which will only be loaded based off of certain conditions in the game (such as the current level being played).

### When to use LoadedOnlyWhenReferenced

LoadedOnlyWhenReferenced is very useful if you have content in your game which is optionally loaded depending on the state of your game. For example, you may have a game where levels are represented by .scnx files. You may add multiple .scnx files to your Screen and mark them as LoadedOnlyWhenReferenced. This means that by default no files will be loaded when your Screen is created. However, if you access any properties created for the files in the Screen, then the corresponding file will be loaded.

### Additional Information

* [Optionally Loaded Content tutorial](https://github.com/flatredball/FlatRedBallDocs/blob/main/frb/docs/index.php) - Basic tutorial on how to use optionally loaded content.
* [Optionally Loaded Scenes](https://github.com/flatredball/FlatRedBallDocs/blob/main/frb/docs/index.php) - Discusses how to create optionally loaded Scenes (.scnx files) to load levels dynamically.


---

# 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/flatredball/glue-reference/files/glue-reference-loadedonlywhenreferenced.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.
