[Easy to use plug-in] Unity optimized automatic packaging of atlas texturePacker

1: The first step is to download and import texturePacker Importer into the Unity project.

2: Download texturePacker URL:

Download texturepacker 7.0.3 for Windows (64 bit)

After installation, run it and start the trial of the professional version (7 days)

3: Some attributes are referenced as follows:

Note: This Image folder is dragged directly into the unity project . It contains all the pictures that need to be packaged into an atlas. This software will automatically package the atlas for us.

4: Click "Publish Spritesheet" above the head

Two files will be generated: one in png format and one in tpsheet

5: Drag both files into the project

At this time, the texturePacker Importer we first imported will automatically split "Atlas.png":

6: Code part

First put the atlas into the new location: Resources=>Packer

public class GetImage : MonoBehaviour
{
    public Image image;
    void Start()
    {
        image.sprite = GetPlistElement("图集", "Player_0");
    }

    /// <summary>
    /// 获得图集元素
    /// </summary>
    /// <param name="plist_name"></param>
    /// <param name="element_name"></param>
    /// <returns></returns>
    public Sprite GetPlistElement(string plist_name, string element_name)
    {
        Sprite[] sprites = Resources.LoadAll<Sprite>("Packer/" + plist_name);
        for (int i = 0; i < sprites.Length; i++)
        {
            if (sprites[i].name == element_name)
            {
                return sprites[i];
            }

        }
        return null;
    }


run:

                                                                       ↓     ↓    ↓

 

Guess you like

Origin blog.csdn.net/m0_74022070/article/details/130942259