Changes
Jump to navigation
Jump to search
← Older edit
Newer edit →
Modding:Modder Guide/APIs/Content
(view source)
Revision as of 01:09, 26 July 2018
193 bytes added
,
01:09, 26 July 2018
→Replace an asset entirely
:
tweak example to make it clearer how to handle multiple assets
Line 144:
Line 144:
public bool CanLoad<T>(IAssetInfo asset)
public bool CanLoad<T>(IAssetInfo asset)
{
{
−
return
asset.AssetNameEquals("Portraits/Abigail");
+
if (
asset.AssetNameEquals("Portraits/Abigail")
)
+
return true;
+
+
return false
;
}
}
Line 151:
Line 154:
public T Load<T>(IAssetInfo asset)
public T Load<T>(IAssetInfo asset)
{
{
−
return this.Helper.Content.Load<T>("assets/abigail-portaits.png", ContentSource.ModFolder);
+
if (asset.AssetNameEquals("Portraits/Abigail"))
+
return this.Helper.Content.Load<T>("assets/abigail-portaits.png", ContentSource.ModFolder
);
+
+
throw new InvalidOperationException($"Unexpected asset '{asset.AssetName}'."
);
}
}
}
}
Pathoschild
translators
8,437
edits
Navigation menu
Personal tools
Create account
Log in
Namespaces
Modding
Discussion
Variants
Views
Read
View source
View history
More
Search
Navigation
Main page
Recent changes
Admin noticeboard
Help Editing
Random page
Official Links
Official Site
Official Forums
Official Merchandise
Discord
Reddit
Tools
Upload file
Special pages
Printable version