5 Star 19 Fork 13

glegoo / ngui-cocos-creator-convertor

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

插件说明

需求将Unity项目移植到CocosCreator(H5). 如果UI全部重拼一遍太费时费力. 故抽出时间写了这个扩展. 用于Unity NGUI制作的UI prefab移植到Cocos Creator.

NGUI版本: 3.8.2
CocosCreator版本: 1.9.0

暂时没精力顾及其他版本, 只用到一些基础方法, 如果有API变动请自行修改.

工作原理

将Unity中prefab的节点父子结构, 以及节点上NGUI的UISprite, UILabel, UITexture等控件的有用信息保存至json文件. 在CocosCreator中解析后再创建.

目前可移植项:

  • 节点: position, scale, rotation(仅z轴), active, name
  • UIWidget: 锚点信息, 宽高, 颜色
  • UISprite, UITexture: 图集, 图片, 是否使用Slice, 九宫格Border信息
  • UILabel: 字号, 描边颜色宽度, overflow, 对齐方式, 行间距, bitmap字体(字间距)
  • 带有BoxCollider的节点会被挂载UIButton
  • 子节点按UIWidget的depth排序
  • ScrollView + Grid: 不完美移植,由于两方控件区别较大, 暂时没想到什么好方法完美移植. 现阶段支持使用最多的竖排列表的移植, 移植后需微调间距等数值.

可以覆盖大部分需求.

使用方法

  1. Unity 文件夹内文件放至Unity工程内. 在Prefab上右键导出Json文件.
  2. prefab-creator 文件夹放至CocosCreator工程packages目录下. 在扩展菜单中选择 Prefab生成工具 打开扩展窗口. 配置导出路径以及图片文件夹. 图片/字体文件夹内放入需要的资源, 支持图集和散图, 图集文件名/图集内图片文件名/散图文件名/字体文件名要与Unity端一致!!!. 之后拖入第一步导出的Json文件, 点生成即可.
  3. 首次创建时需要加载文件夹内的所有图片, 根据图片数量可能需要较长时间. 所以建议移除文件夹内的无用图片资源.

效果预览

领个红包支持一下吧:moneybag:

MIT License Copyright (c) 2020 glegoo Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

Unity Ngui制作的UI prefab转换成Cocos Creator prefab工具 展开 收起
JavaScript 等 2 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
JavaScript
1
https://gitee.com/glegoo/ngui-cocos-creator-convertor.git
git@gitee.com:glegoo/ngui-cocos-creator-convertor.git
glegoo
ngui-cocos-creator-convertor
ngui-cocos-creator-convertor
master

搜索帮助