Loading Custom Sprites
Sprite Collection Recap
Adding an Embedded PNG
//The resource path of the embedded texture in your project files (Make sure to embed your texture as if it were an item sprite)
//The resource path should be formatted as "Namespace / Folders / Texture Name". In the below example, you can see the path to a texture called example_texture_001, in the folder Effects, which itself is in the folder Resources. All of this is in the hypothetical namespace MyNameSpace.
string resourcePath = "MyNameSpace/Resources/Effects/example_texture_001";
//The collection we will be adding a sprite to. This can, in theory, be any sprite collection, however most modded content adds to the itemCollection, which is easily accessible in Alexandria's SpriteBuilder class.
tk2dSpriteCollectionData collection = SpriteBuilder.itemCollection;
//The string id we want for the texture after it's added
string name = "example_texture_001";
//We provide all the above examples to the AddSpriteToCollection method to package our embedded texture into the existing itemCollection.
int addedSpriteID = SpriteBuilder.AddSpriteToCollection(resourcePath, collection, name);
//This returns the integer Id of the added sprite in the collection, which you could choose to save if you need to use it later, or just ignore.Loading from an Asset Bundle
Last updated
Was this helpful?