Interface IAsset
- Namespace
- Vintagestory.API.Common
- Assembly
- VintagestoryAPI.dll
Represents a loaded asset from the assets folder
public interface IAsset
- Extension Methods
Properties
Data
The file contents in binary format
byte[] Data { get; set; }
Property Value
- byte[]
FullFilePath
Only set if AssetManager.Debug is on. Contains the full file path of the asset on disk.
string FullFilePath { get; set; }
Property Value
IsPatched
Set to true if the asset has been patched by JsonPatchLoader - if so, we don't want to unload it
bool IsPatched { get; set; }
Property Value
Location
The AssetLocation of the asset.
AssetLocation Location { get; }
Property Value
Name
The assets Filename
string Name { get; }
Property Value
Origin
The origin informaton of the asset.
IAssetOrigin Origin { get; set; }
Property Value
Methods
IsLoaded()
Whether or not the asset is currently loaded.
bool IsLoaded()
Returns
ToBitmap(ICoreClientAPI)
Turns the binary data into a Bitmap. Use for .png images. Does not work on other image formats.
BitmapRef ToBitmap(ICoreClientAPI capi)
Parameters
capiICoreClientAPI
Returns
ToObjectFast<T>(string)
If the asset is a json file you can use this convenience method to turn it into an object using strict syntax via System.Text.Json
T ToObjectFast<T>(string domain)
Parameters
domainstring
Returns
- T
Type Parameters
T
ToObject<T>(JsonSerializerSettings)
If the asset is a json file you can use this convenience method to turn it into an object using forgiving syntax via Newtonsoft.Json
T ToObject<T>(JsonSerializerSettings settings = null)
Parameters
settingsJsonSerializerSettingsSettings for the Json Serializer.
Returns
- T
Type Parameters
TAttempts to convert the asset into the given type.
ToText()
Turns the binary data into a UTF-8 string. Use for text files.
string ToText()