-
UID:6
-
- 注册时间2009-07-30
- 最后登录2018-04-01
- 在线时间175小时
-
- 发帖206
- 搜Ta的帖子
- 精华0
- 铜币256
- 威望175
- 贡献值1
- 银元0
- 好评度0
-
访问TA的空间加好友用道具
|
NGUI版本:3.6.51、参见SZUIAtlasMakerRuntimeTest设置相应的值以上值需要提前设置好 2、没有检查是否atlas能够正确创建,自己可以改,加入返回值 3、代码都是在NGUI里面拷贝出来的,只是进行改动,没有新代码 4、适用与那种从网上下图片,之后还不想用UITexture的人,但是还是建议用UITexture如果drawcall不是问题的话 5、自己以后更新按我的方式改改就可以 6、动态创建速度较慢,建议在游戏启动的时候运行 7、游戏时可以将创建的atlas保存到可写目录,避免每次都新创建SZUIAtlasMakerRuntimeTest.cs- using UnityEngine;
- using System.Collections;
- public class SZUIAtlasMakerRuntimeTest : MonoBehaviour {
- public Texture2D[] texs;
- public UISprite sprite;
- private UIAtlas atlas;
- void Start () {
- SZUIAtlasMakerRuntime.atlasTrimming = true;
- SZUIAtlasMakerRuntime.atlasPMA = atlas != null ? atlas.premultipliedAlpha : false;
- SZUIAtlasMakerRuntime.unityPacking = false;
- SZUIAtlasMakerRuntime.atlasPadding = 1;
- SZUIAtlasMakerRuntime.allow4096 = true;
- SZUIAtlasMakerRuntime.UITexturePacker.forceSquareAtlas = true;
- if (atlas == null)
- {
- atlas = this.gameObject.AddComponent<UIAtlas>();
- }
- string lastName = string.Empty;
- foreach (var tex in texs)
- {
- SZUIAtlasMakerRuntime.AddOrUpdate(atlas, tex);
- lastName = tex.name;
- }
- sprite.atlas = atlas;
- sprite.spriteName = lastName;
- }
- }
|