๐ฃOverview
Introduction
You can load resources in different ways.
Get resources in game
You can get Resources structure in Resources
Sprite
Single sprite
It is common to get a single sprite through SpriteTextureLoader.getSprite(string path) manually.
Parameter path is the path to the sprite resource in Resources(a unity class).
Such as
SpriteTextureLoader.getSprite("ui/icons/iconOption")Sprite list
It is common to get a list of sprites through SpriteTextureLoader.getSpriteList(string path) manually.
It is Resources.LoadAll with cache. Parameter path is the path to the sprites resources in Resources.
Such as
SpriteTextureLoader.getSpriteList("effects/projectiles/arrow")Others
For other resources, you can load them through Resources.Load or Resources.LoadAll.
Add resources to game
Add resources automatically
It only supports to add sprites and text automatically.
Make a folder named "GameResources" in your mod folder and see it as "Resources" folder in unity. Place your pictures or texts in it. It's case-insensitive about folder and file name.
For sprite, you can configure your sprite through sprites.json or *.meta(if you dont know what's meta file in unity, just use sprites.json).
sprites.json
A sprites.json file will be deserialized into an instance of SpritesSettings.
Definition of SpritesSettings:
class SpritesSettings
{
    public Setting Default;
    public List<Setting> Specific;
}
class Setting
{ 
    public float BorderB = 0.0f; // border bottom
    public float BorderL = 0.0f; // border left
    public float BorderR = 0.0f; // border right
    public float BorderT = 0.0f; // border top
    public string Path = "\\";   // corresponded file path
    public float PivotX = 0.5f;  // pivot x, default to be center
    public float PivotY = 0.0f;  // pivot y, default to be center
    public float PixelsPerUnit = 1f; // if you dont know what it is, keep it 1
    public float RectX = 0.0f;   // keep it 0 now
    public float RectY = 0.0f;   // keep it 0 now
}Default setting will be applied to files which have not Specific setting.
*.meta
It is a meta file generated by unity, it is used to load atlas or sprite sheet.
Patch resources manually
Get resources in real file system
Last updated