Mod Tutorial
  • 🏠Home
  • 😀Introduction
  • 😇Player Manual
    • 📕Installation
    • 📔How to use it
    • 🐴Attention
  • 😅Make Mod
    • 😅Prepare
    • 😎Create a mod
    • 😘Common Features of NML
    • 🤔Others Common
    • 🥸BepInEx
  • 🤔Basic Concepts
    • 👌Mod Declaration
    • 🎨Mod Interface
    • 🥳Mod Configuration
    • 👍Mod Dependency
    • 🤗Multiligual
  • 😶‍🌫️Resources
    • 😣Overview
    • 😮Resources
    • 😣AssetBundle
  • 😪Other techs
    • 👌Mod Reload
    • 🫥Event Handle
    • 😫Mod Upload
  • 🫨Game Contents
    • 🥳Create Equipment Asset
  • 🤩User Interface
    • 😁Button
    • 😂Tab
    • 😄Prefab
    • 😆Common Window
    • 😋Autolayout Window
  • 😘Packed
    • 😍Basic Mod
  • 🚗NML Development and OpenMods Projects
    • Introduction
    • NML Development
    • NML Documentation
    • Example Mod
    • Unity Development Toolkit
    • Game Documentation
Powered by GitBook
On this page
  • Introduction
  • Get resources in game
  • Sprite
  • Others
  • Add resources to game
  • Add resources automatically
  • Patch resources manually
  • Get resources in real file system
  1. Resources

Overview

PreviousMultiligualNextResources

Last updated 1 year ago

Introduction

You can load resources in different ways.

Get resources in game

You can get Resources structure in

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

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

For other resources, you can load them through or .

😶‍🌫️
😣
Resources
Resources.Load
Resources.LoadAll
Example of sprite.json