Asset Utils
Util functions related to loading assets at runtime.
Loading 2D textures
Loading 2D textures at runtime can be done through the AssetUtils.LoadTexture static function.
Example
For the following folder structure
BepInEx\
plugins\
MyMod.dll
MyTexture.jpg
we can load a 2D texture dynamically by doing the following anywhere in our codebase
Texture2D texture = AssetUtils.LoadTexture("MyTexture.jpg");
this texture object can now be used as a sprite for an item, or anything else. For example, creating a sprite
Texture2D texture = AssetUtils.LoadTexture("MyTexture.jpg");
Sprite sprite = Sprite.Create(texture, new Rect(0f, 0f, texture.width, texture.height), Vector2.zero);
Loading models
Loading .obj models at runtime can be done through the AssetUtils.LoadMesh static function.
Example WIP