/// <summary>/// 使表情生成prefab/// </summary>[MenuItem("SpritesPacker/_使互动表情生成prefabs-别乱点")]public static void MakeStickerAtlas(){UnityEngine.Debug.Log("碎图 表情--用时再打开");return;//用时再打开string parentPath = Application.dataPath + "/Resources/Prefab/Stickers";if (Directory.Exists(parentPath) == false)Directory.CreateDirectory(parentPath);//图片原路径DirectoryInfo uiStickers = new DirectoryInfo(Application.dataPath + "/Art/UI/Stickers");foreach (DirectoryInfo item in uiStickers.GetDirectories())//可以有子文件夹{string tempPath = parentPath + "/" + Path.GetFileName(item.FullName);if (Directory.Exists(parentPath + Path.GetFileName(item.FullName)) == false){
//prefab生成在该目录中Directory.CreateDirectory(parentPath + "/" + Path.GetFileName(item.FullName));}foreach (FileInfo pngItem in item.GetFiles("*.png", SearchOption.AllDirectories)){string allPath = pngItem.FullName;string assetPath = allPath.Substring(allPath.IndexOf("Assets"));Sprite sprite = AssetDatabase.LoadAssetAtPath<Sprite>(assetPath);GameObject go = new GameObject(sprite.name);go.AddComponent<SpriteRenderer>().sprite = sprite; allPath = tempPath + "/" + sprite.name + ".prefab";string prefabPath = allPath.Substring(allPath.IndexOf("Assets"));PrefabUtility.CreatePrefab(prefabPath, go);GameObject.DestroyImmediate(go);}}}
详细解决方案
Sprites,Editor使图片生成prefab
热度:76 发布时间:2024-01-18 06:57:13.0
相关解决方案
- MyEclipse8.0怎么安装Visual Editor-Update-1.4.0
- fck editor 修改文章的有关问题
- 无法为类型 CuteEditor.Editor 授予有效的许可证(发布后)解决方案
- 哪位高手有abap eclipse editor
- 求SQL Editor 1.2.2解决方案
- 求SQL Editor 1.2.2解决思路
- MyEclipse 装配插件后Myeclipse Could not open the editor: Invalid thread access
- 没设置 SVN_EDITOR,VISUAL 或 EDITOR 环境变量"的解决方
- can't opening the editor.这是怎么回事?
- visual editor 插件什么作用
- 求1st JavaScript Editor,该如何处理
- Kind Editor 编辑器 图片下传
- CSS sprites 技术应用心得
- eclipse插件-Eclipse HTML Editor Plugin
- CSS Sprites 图片调整技术
- 关于 res://ieframe.dll/dnserror.htm#http://fckeditor/editor/fckeditor.html?I无法显示有关问题
- css sprites(良好很强大)(zz)
- CSS Sprites: CSS图片合龙技术详解(ZZ)
- CSS图片分割 CSS Sprites 将多个背景集成到一个png图片下CSS定位
- Eclipse适用插件-Eclipse HTML Editor Plugin
- Eclipse中装配可以新建html文件的插件(Eclipse HTML Editor)
- 网页设计中审慎使用CSS sprites
- Eclipse 中 PHP Editor 联系关系 CakePHP *ctp 文件
- easyui datagrid editor 的text添加长度验证~该如何解决
- Could not open the editor: An unexpected exception was thrown 异常
- GitHub最新趋势:一款可以直接编辑页面文字的JS插件-Pen Editor
- jquery easyui datagrid editor 参数传递解决思路
- IE10 FCK Editor 不支持selectSingleNode 怎么解决
- kissy editor 阶段感受
- 在eclipse中打开少数jsp文件发生Error opening the editor