资源简介
可以将图集裁剪成小图片导出,不会使用ps可以这样将自己喜欢的小图片导出。

代码片段和文件信息
#define USE_NGUI
#if USE_NGUI
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text;
using UnityEditor;
using FreeImageAPI;
public class AtlasUtil
{
class frame
{
public string name;
public Rect frame;
public bool rotated;
public bool trimmed;
public Rect spriteSourceSize;
public Vector2 sourceSize;
}
class Atlasmeta
{
public string app;
public string version;
public string image;
public string format;
public Vector2 size;
public float scale;
public string smartupdate;
}
class AtlasImage
{
public Listame> frames = new Listame>();
public Atlasmeta meta = new Atlasmeta();
}
public static void Export(UIAtlas atlas)
{
Export(atlas @“E:\\tmp\\“);
}
public static void Export(UIAtlas atlas string folder)
{
AtlasImage atlasImage = new AtlasImage();
atlasImage.meta.app = “http://www.texturepacker.com“;
atlasImage.meta.version = “1.0“;
atlasImage.meta.image = atlas.spriteMaterial.mainTexture.name + “.png“;
atlasImage.meta.format = “RGBA8888“;
atlasImage.meta.size = new Vector2(atlas.spriteMaterial.mainTexture.width atlas.spriteMaterial.mainTexture.height);
atlasImage.meta.scale = 1.0f;
atlasImage.meta.smartupdate = ““;
foreach (UIAtlas.Sprite sp in atlas.spriteList)
{
frame frame = new frame();
frame.trimmed = false;
frame.rotated = sp.rotated;
int frameX = Mathf.RoundToInt( sp.outer.xMin );
int frameY = Mathf.RoundToInt(sp.outer.yMin);
int frameW = Mathf.RoundToInt(sp.outer.width);
int frameH = Mathf.RoundToInt(sp.outer.height);
if ( sp.rotated )
{
int tmp = frameW;
frameW = frameH;
frameH = tmp;
}
frame.frame = new Rect(frameX frameY frameW frameH);
frame.spriteSourceSize = new Rect(0 0 frameW frameH);
frame.sourceSize = new Vector2(frameW frameH);
frame.name = sp.name + “.png“;
atlasImage.frames.Add(frame);
}
folder = GetFolder(folder atlas.spriteMaterial.mainTexture.name);
Save(atlasImage folder atlas.spriteMaterial.mainTexture.name);
SplitImage(atlas.spriteMaterial.mainTexture atlasImage folder);
Debug.Log(“Done Export atlas “ + atlas.name);
}
static string GetFolder(string rootDir string texname)
{
if (!Directory.Exists(rootDir))
Directory.CreateDirectory(rootDir);
string folder = Path.Combine(rootDir texname);
if (!Directory.Exists(folder))
Directory.CreateDirectory(folder);
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
..A..H. 178 2015-04-26 21:45 AtlasWindow.cs.me
文件 3374592 2014-03-23 15:03 FreeImage.dll
..A..H. 90 2015-05-23 07:54 FreeImage.dll.me
文件 189440 2015-02-08 17:58 FreeImageNET.dll
..A..H. 153 2015-05-23 07:54 FreeImageNET.dll.me
文件 11165 2015-04-26 22:01 AtlasUtil.cs
..A..H. 178 2015-04-26 21:45 AtlasUtil.cs.me
文件 1642 2015-04-27 23:07 AtlasWindow.cs
----------- --------- ---------- ----- ----
3577438 8
- 上一篇:大数据hapdoop安装完整实验报告包含结果图
- 下一篇:图书后台管理
相关资源
- Scratch 变脸(将人物图片变成各种各样
- 基于MFC扩展CListCtrl子项显示图片并叠
- 在大图中查找小图显示位置
- Img2Lcd(将图片转换为数组的工具)
- Unity3D登录界面工程
- unity3d反编译工具
- 图片存储到数据库保存二进制文件并
-
图片和xm
l格式互换 - 将yuv各种格式的图片转换为jpg格式的
- 傻瓜式的图片去水印下载
- 图片上传组件v1.0
- 230张网页背景图片(网页制作)
-
UnityWebPla
yer及UnityWebPla yerFull -
UnityWebPla
yerFull - 超强JPG图片压缩工具,减小图片文件
- unity4.0官方正式版
- 百度图片识别源码.rar
- 常用电子元器件图片识别
- eclipse安卓工程相册、相机选择图片功
- Qt图片浏览器 --基于Qt的Graphics View f
- Delphi图片按钮控件,很好用
- 从图片中读取条形码
- delphi外部图片拖拽
- 基于V4L2的视频采集,能够采集YUVJPE
- css3图片放大缩小切换幻灯片效果
- delphi基于gdi+的图片旋转任意角度
- 易语言图片快速无极限
- 易语言图片放大
- cropper.js h5裁剪上传图片 代码齐整
- 仿QQ头像裁剪功能
评论
共有 条评论