Changes

→‎Edit an asset after it's loaded: clarify how CanEdit / Edit are called
Line 58: Line 58:  
==Edit the game's assets==
 
==Edit the game's assets==
 
===Edit an asset after it's loaded===
 
===Edit an asset after it's loaded===
You can edit any of the game's assets after it's loaded from the file (but before it's provided to the game), without changing the original files. You do this by implementing <tt>IAssetEditor</tt> in your <tt>Mod</tt> class, which adds two methods: <tt>CanEdit&lt;T&gt;</tt> returns whether the mod can edit a particular asset, and <tt>Edit&lt;T&gt;</tt> makes any changes needed.
+
You can edit any of the game's assets after it's loaded from the file (but before it's provided to the game), without changing the original files. You do this by implementing <tt>IAssetEditor</tt> in your <tt>Mod</tt> class, which adds two methods: <tt>CanEdit&lt;T&gt;</tt> returns whether the mod can edit a particular asset, and <tt>Edit&lt;T&gt;</tt> makes any changes needed. SMAPI will call your <tt>CanEdit&lt;T&gt;</tt> every time an asset is loaded (which may happen multiple times per asset), then call <tt>Edit&lt;T&gt;</tt> if it returns true.
    
For example, here's a mod which makes crops grow in any season and changes the winter dirt texture.
 
For example, here's a mod which makes crops grow in any season and changes the winter dirt texture.
translators
8,404

edits