The examples in this article share with you the specific code of converting Unity's cut picture album into multiple pictures for your reference. The specific content is as follows
This is a tool that seems to be online. It is used to cut the picture album into multiple formats in Unity and change these sprites into one picture. The cutting speed is too slow. When there are many pictures in the picture album, some pictures will be lost. I will further improve and modify this blog if I have time.
1. First select the picture album to be cut, select the texture type as default, and check read/Write Enabled under Advanced.
Change the type to sprite(2D and UI), and select Multiple to apply.
3. Click Sprite Editor to cut the picture.
4. Right-click the picture album and select imageslicer and select process to Sprites.
5. Wait for the cutting to be completed.
The script is as follows:
using UnityEngine; using ; using UnityEditor; using ; using ; /// <summary> /// Cutting/// </summary> public static class ImageSlicer { [MenuItem("Assets/ImageSlicer/Process to Sprites")] static void ProcessToSprite() { Texture2D image = as Texture2D;//Get the rotated object string rootPath = ((image));//Get the path name string path = rootPath + "/" + + ".PNG";//Picture path name TextureImporter texImp = (path) as TextureImporter;//Get the picture entrance (rootPath, );//Create a folder foreach (SpriteMetaData metaData in )//Travel the small picture collection { Texture2D myimage = new Texture2D((int), (int)); //abc_0:(x:2.00, y:400.00, width:103.00, height:112.00) for (int y = (int); y < + ; y++)//Y-axis pixels { for (int x = (int); x < + ; x++) (x - (int), y - (int), (x, y)); } //Convert texture to EncodeToPNG compatible format if ( != TextureFormat.ARGB32 && != TextureFormat.RGB24) { Texture2D newTexture = new Texture2D(, ); ((0), 0); myimage = newTexture; } var pngData = (); //(myimage, rootPath + "/" + + "/" + + ".PNG"); (rootPath + "/" + + "/" + + ".PNG", pngData); // Refresh the resource window interface (); } } }
The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.