TModLoader v1.4.4.9
TModLoader source code documentation
Loading...
Searching...
No Matches

◆ Request< T >()

static Asset< T > Terraria.ModLoader.ModContent.Request< T > ( string name,
AssetRequestMode mode = AssetRequestMode::AsyncLoad )
inlinestatic

Gets the asset with the specified name. Throws an Exception if the asset does not exist.

Parameters
nameThe path to the asset without extension, including the mod name (or Terraria) for vanilla assets. Eg "ModName/Folder/FileNameWithoutExtension"
modeThe desired timing for when the asset actually loads. Use ImmediateLoad if you need correct dimensions immediately, such as with UI initialization
Type Constraints
T :class 

Definition at line 131 of file ModContent.cs.

131 : class
132 {
133 SplitName(name, out var modName, out var subName);
134 if (Main.dedServ && Main.Assets == null)
135 {
136 Main.Assets = new AssetRepository(null);
137 }
138 if (modName == "Terraria")
139 {
140 return Main.Assets.Request<T>(subName, mode);
141 }
142 if (!ModLoader.TryGetMod(modName, out var mod))
143 {
144 throw new MissingResourceException(Language.GetTextValue("tModLoader.LoadErrorModNotFoundDuringAsset", modName, name));
145 }
146 return mod.Assets.Request<T>(subName, mode);
147 }
static string GetTextValue(string key)
Retrieves the text value for a specified localization key. The text returned will be for the currentl...
Definition Language.cs:35
Contains methods to access or retrieve localization values. The Localization Guideteaches more about ...
Definition Language.cs:12
static void SplitName(string name, out string domain, out string subName)
Definition ModContent.cs:84

References Terraria.Main.Assets, Terraria.Main.dedServ, Terraria.Localization.Language.GetTextValue(), Terraria.ModLoader.ModContent.SplitName(), and Terraria.ModLoader.ModLoader.TryGetMod().

Referenced by Terraria.ModLoader.ModContent.RequestIfExists< T >().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: