RuntimeType
Last updated
Last updated
The RuntimeType property controls the type that contains the data loaded from a given file when the game is running. Some types, such as .wav files, can be loaded into multiple runtime types such as SoundEffect
and SoundEffectInstance
.
If you are adding a new file using the Add File window, the runtime type is displayed in the window. For example, notice that a Texture is created (Texture2D in code) when selecting a .png file type.
When a new file is added, the RuntimeType is automatically selected.
Similarly, if a new PNG is added by drag+dropping the file into the FRB editor, the runtime type is selected automatically based on the file's extension. Usually this does not need to be changed.
The selected runtime type ultimately controls the type of the property created in the Screen, Entity, or Global Content. For example, MyFile.png is loaded as a Texture2D as shown in the following screenshot of Visual Studio:
Files may be loaded as fields or properties depending on properties assigned on the file in the FRB Editor.
RuntimeTypes can be changed through the dropdown in the Properties window. FlatRedBall provides options for the file according to its extension.
Some file types may only have a single RuntimeType associated with the extension.
Other types may provide multiple runtime types, such as SoundEffect and SoundEffectInstance for .wav files.
FlatRedBall provides standard RuntimeTypes for many extensions, but plugins can add additional runtime types. You can even create your own plugins to load your files into types that are not supported by FlatRedBall out of the box.
RuntimeType should not be changed through the dropdown if the file is a wildcard file. To change the runtime type, the edit must be performed in the .gluj file for global content. Be careful, you must assign a type that is understood by FRB or currently-loaded plugins.