Unity3D 预设打包的注意事项
在平时的开发中,把预设打包成 assetbundle 文件是非常普遍的做法,但是我们不能随便把预设打包成 assetbundle 就算完事,我们应该先清楚把预设打包成 assetbundle 的目的,通常我们把预设打包成 assetbundle 文件是为了压缩预设的文件尺寸以方便从网络快速加载,既然这样,我们就应该知道打包预设的时候应该注意哪些问题。
我们先创建测试环境,场景中的 Stamp7 与 Stamp9 网格不同,但是材质相同,R1_Column1 与 Stamp7 以及 Stamp9 的网格、材质都不相同,场景如图:
.imageplus-append-lu-img-txt { overflow: hidden; margin: 10px 0; font-family: Microsoft YaHei; line-height: normal }
.imageplus-append-lu-img-txt .imageplus-append-content .imageplus-append-img-txt-ad-item { float: left; position: relative; height: 90px; width: 125px }
.imageplus-append-lu-img-txt .imageplus-append-content .imageplus-append-img-txt-ad-item .imageplus-append-img-txt-ad-item-img img { height: 100%; width: 100% }
.imageplus-append-lu-img-txt .imageplus-append-content .imageplus-append-img-txt-ad-item .imageplus-append-img-txt-ad-item-desc { position: absolute; bottom: 0; left: 0; width: 100%; height: 18px; line-height: 18px; font-size: 14px; text-align: center; color: #fff; background-color: rgba(0,0,0,0.6); text-decoration: none }
.imageplus-append-lu-img-txt .imageplus-append-content .imageplus-append-img-txt-ad-item .imageplus-append-img-txt-ad-item-desc span { color: #fff }
.imageplus-append-lu-img-txt .imageplus-append-content .imageplus-append-img-txt-ad-item:hover .imageplus-append-img-txt-ad-item-img { border: 2px solid #f60 }
.imageplus-append-close-btn { display: none }
.imageplus-baidu-logo { position: absolute; bottom: 0; right: 0; z-index: 9999; background: url("http://ecma.bdimg.com/public03/imageplus/logo.png") no-repeat; background-position: 0 -17px; width: 16px; height: 16px }
.imageplus-ad-logo { position: absolute; left: 0; bottom: 0; overflow: hidden; z-index: 12; background: url("http://ecma.bdimg.com/public03/imageplus/logo.png") no-repeat; background-position: 0 0; width: 34px; height: 16px }
.imageplus-append { float: none; margin: 0; padding: 0; border: 0; overflow: hidden; visibility: visible; text-align: left; background: transparent; position: relative; text-indent: 0; display: inline-block }
.imageplus-append div { float: none; margin: 0; padding: 0; border: 0; overflow: hidden; position: static; display: block; visibility: visible; text-align: left; background: transparent; font-family: Microsoft YaHei; line-height: normal }
.imageplus-append a,.imageplus-append img,.imageplus-append span { float: none; margin: 0; padding: 0; border: 0; overflow: visible; position: static; display: inline; visibility: visible; text-align: left; background: transparent; font-family: Microsoft YaHei; line-height: normal }
接着我们把场景的子对象(场景中的 Stamp7、Stamp9、R1_Column1)先做成预设,如图:
.imageplus-append-lu-img-txt { overflow: hidden; margin: 10px 0; font-family: Microsoft YaHei; line-height: normal }
.imageplus-append-lu-img-txt .imageplus-append-content .imageplus-append-img-txt-ad-item { float: left; position: relative; height: 90px; width: 125px }
.imageplus-append-lu-img-txt .imageplus-append-content .imageplus-append-img-txt-ad-item .imageplus-append-img-txt-ad-item-img img { height: 100%; width: 100% }
.imageplus-append-lu-img-txt .imageplus-append-content .imageplus-append-img-txt-ad-item .imageplus-append-img-txt-ad-item-desc { position: absolute; bottom: 0; left: 0; width: 100%; height: 18px; line-height: 18px; font-size: 14px; text-align: center; color: #fff; background-color: rgba(0,0,0,0.6); text-decoration: none }
.imageplus-append-lu-img-txt .imageplus-append-content .imageplus-append-img-txt-ad-item .imageplus-append-img-txt-ad-item-desc span { color: #fff }
.imageplus-append-lu-img-txt .imageplus-append-content .imageplus-append-img-txt-ad-item:hover .imageplus-append-img-txt-ad-item-img { border: 2px solid #f60 }
.imageplus-append-close-btn { display: none }
.imageplus-baidu-logo { position: absolute; bottom: 0; right: 0; z-index: 9999; background: url("http://ecma.bdimg.com/public03/imageplus/logo.png") no-repeat; background-position: 0 -17px; width: 16px; height: 16px }
.imageplus-ad-logo { position: absolute; left: 0; bottom: 0; overflow: hidden; z-index: 12; background: url("http://ecma.bdimg.com/public03/imageplus/logo.png") no-repeat; background-position: 0 0; width: 34px; height: 16px }
.imageplus-append { float: none; margin: 0; padding: 0; border: 0; overflow: hidden; visibility: visible; text-align: left; background: transparent; position: relative; text-indent: 0; display: inline-block }
.imageplus-append div { float: none; margin: 0; padding: 0; border: 0; overflow: hidden; position: static; display: block; visibility: visible; text-align: left; background: transparent; font-family: Microsoft YaHei; line-height: normal }
.imageplus-append a,.imageplus-append img,.imageplus-append span { float: none; margin: 0; padding: 0; border: 0; overflow: visible; position: static; display: inline; visibility: visible; text-align: left; background: transparent; font-family: Microsoft YaHei; line-height: normal }
然后我们分别把这三个文件打包成 assetbundle 文件,并观察生成 assetbundle 文件大小,如图:
.imageplus-append-lu-img-txt { overflow: hidden; margin: 10px 0; font-family: Microsoft YaHei; line-height: normal }
.imageplus-append-lu-img-txt .imageplus-append-content .imageplus-append-img-txt-ad-item { float: left; position: relative; height: 90px; width: 125px }
.imageplus-append-lu-img-txt .imageplus-append-content .imageplus-append-img-txt-ad-item .imageplus-append-img-txt-ad-item-img img { height: 100%; width: 100% }
.imageplus-append-lu-img-txt .imageplus-append-content .imageplus-append-img-txt-ad-item .imageplus-append-img-txt-ad-item-desc { position: absolute; bottom: 0; left: 0; width: 100%; height: 18px; line-height: 18px; font-size: 14px; text-align: center; color: #fff; background-color: rgba(0,0,0,0.6); text-decoration: none }
.imageplus-append-lu-img-txt .imageplus-append-content .imageplus-append-img-txt-ad-item .imageplus-append-img-txt-ad-item-desc span { color: #fff }
.imageplus-append-lu-img-txt .imageplus-append-content .imageplus-append-img-txt-ad-item:hover .imageplus-append-img-txt-ad-item-img { border: 2px solid #f60 }
.imageplus-append-close-btn { display: none }
.imageplus-baidu-logo { position: absolute; bottom: 0; right: 0; z-index: 9999; background: url("http://ecma.bdimg.com/public03/imageplus/logo.png") no-repeat; background-position: 0 -17px; width: 16px; height: 16px }
.imageplus-ad-logo { position: absolute; left: 0; bottom: 0; overflow: hidden; z-index: 12; background: url("http://ecma.bdimg.com/public03/imageplus/logo.png") no-repeat; background-position: 0 0; width: 34px; height: 16px }
.imageplus-append { float: none; margin: 0; padding: 0; border: 0; overflow: hidden; visibility: visible; text-align: left; background: transparent; position: relative; text-indent: 0; display: inline-block }
.imageplus-append div { float: none; margin: 0; padding: 0; border: 0; overflow: hidden; position: static; display: block; visibility: visible; text-align: left; background: transparent; font-family: Microsoft YaHei; line-height: normal }
.imageplus-append a,.imageplus-append img,.imageplus-append span { float: none; margin: 0; padding: 0; border: 0; overflow: visible; position: static; display: inline; visibility: visible; text-align: left; background: transparent; font-family: Microsoft YaHei; line-height: normal }
从图中我们可以看出,因为 Stamp7、Stamp9 材质相同,他们生成出来的文件大小差不多大,但是他们是独自打包,所以材质也是独立的,因为材质无法共享。
下面我们把 Trees(包括 Stamp7 与 Stamp9)以及 Stones 也做成预设,如图:
.imageplus-append-lu-img-txt { overflow: hidden; margin: 10px 0 }
.imageplus-append-nova-txt { border: 1px solid #f2f2f2; font-family: Microsoft YaHei; line-height: normal }
.imageplus-append-nova-txt .imageplus-append-content .imageplus-append-nova-txt-ad-item { position: relative; width: 100%; height: 50px; background-color: #fff }
.imageplus-append-nova-txt .imageplus-append-content .imageplus-append-nova-txt-ad-item a { text-decoration: none }
.imageplus-append-nova-txt .imageplus-append-content .imageplus-append-nova-txt-ad-item a:hover { text-decoration: underline }
.imageplus-append-nova-txt .imageplus-append-content .imageplus-append-nova-txt-ad-item div { white-space: nowrap; overflow: hidden; width: auto; height: 25px; line-height: 25px; margin: 0 16px; font-weight: normal }
.imageplus-append-nova-txt .imageplus-append-content .imageplus-append-nova-txt-ad-item .imageplus-append-nova-txt-ad-item-title span { font-size: 14px; font-weight: bold; color: #003397 }
.imageplus-append-nova-txt .imageplus-append-content .imageplus-append-nova-txt-ad-item .imageplus-append-nova-txt-ad-item-desc span { font-size: 12px; color: #333 }
.imageplus-append-jian { width: 20px; height: 20px; background-image: url("http://ecmb.bdimg.com/public03/imageplus_m_append_jian_151204.png"); background-repeat: no-repeat; background-position: 0 0; position: absolute; top: 0; left: 0 }
.imageplus-append-close-btn { width: 40px; height: 40px; position: absolute; right: 0; top: 0; background-image: url("http://ecmb.bdimg.com/public03/imageplus_m_append_close_btn_151113.png"); background-repeat: no-repeat; background-position: 0 0; display: none }
.imageplus-append-logo { height: 18px; width: 18px; background: url("http://cpro.baidustatic.com/cpro/ui/noexpire/img/2.0.1/bg.png") no-repeat left top; position: absolute; right: 0; bottom: 0 }
.imageplus-append-nova-txt-ue2 { font-family: Microsoft YaHei; float: left; border: 1px solid #ddd; border-top: 3px solid #ff2f62; background-color: #f9f9f9 }
.imageplus-append-nova-txt-ue2 a:focus { outline: 0 }
.imageplus-append-nova-txt-ue2 .imageplus-append-content { float: left }
.imageplus-append-nova-txt-ue2 .imageplus-append-content .imageplus-append-nova-txt-ad-item { margin-left: 44px; height: 60px; padding-top: 5px; padding-bottom: 5px }
.imageplus-append-nova-txt-ue2 .imageplus-append-content .imageplus-append-nova-txt-ad-item a { text-decoration: none }
.imageplus-append-nova-txt-ue2 .imageplus-append-content .imageplus-append-nova-txt-ad-item div { white-space: nowrap; overflow: hidden }
.imageplus-append-nova-txt-ue2 .imageplus-append-content .imageplus-append-nova-txt-ad-item .imageplus-append-nova-txt-ad-item-title { height: 30px; line-height: 30px; font-size: 16px }
.imageplus-append-nova-txt-ue2 .imageplus-append-content .imageplus-append-nova-txt-ad-item .imageplus-append-nova-txt-ad-item-title a { color: #000 }
.imageplus-append-nova-txt-ue2 .imageplus-append-content .imageplus-append-nova-txt-ad-item .imageplus-append-nova-txt-ad-item-title .imageplus-append-nova-txt-title-true { float: left }
.imageplus-append-nova-txt-ue2 .imageplus-append-content .imageplus-append-nova-txt-ad-item .imageplus-append-nova-txt-ad-item-title .imageplus-append-nova-txt-title-click { float: left; width: 96px }
.imageplus-append-nova-txt-ue2 .imageplus-append-content .imageplus-append-nova-txt-ad-item .imageplus-append-nova-txt-ad-item-title .imageplus-append-nova-txt-title-click a { color: #ff2f62 }
.imageplus-append-nova-txt-ue2 .imageplus-append-content .imageplus-append-nova-txt-ad-item .imageplus-append-nova-txt-ad-item-desc { height: 26px; line-height: 26px; font-size: 12px }
.imageplus-append-nova-txt-ue2 .imageplus-append-content .imageplus-append-nova-txt-ad-item .imageplus-append-nova-txt-ad-item-desc a { color: #7b7b7b }
.imageplus-append-nova-txt-ue2 .imageplus-append-go-btn { float: right; margin-top: 19px; margin-right: 18px }
.imageplus-append-nova-txt-ue2 .imageplus-append-go-btn a { text-decoration: none }
.imageplus-append-nova-txt-ue2 .imageplus-append-go-btn div { width: 100px; height: 32px; line-height: 32px; text-align: center; background-color: #ff2f62; border: 0; color: #fff; font-family: Microsoft YaHei; font-size: 16px; cursor: pointer }
.imageplus-append-nova-txt-ue2 .imageplus-append-jian { position: absolute; top: 3px; left: 10px; width: 22px; height: 40px; background-image: url("http://ecma.bdimg.com/public03/imageplus/append/nova_txt_star_160426.png"); background-position: 0 0; background-repeat: no-repeat }
.imageplus-append-nova-txt-ue2 .imageplus-append-close-btn { display: none }
.imageplus-append-nova-txt-ue2 .imageplus-append-logo { display: none }
.imageplus-append-nova-txt-ue2 .imageplus-baidu-logo { position: absolute; bottom: 0; right: 0; z-index: 9999; background: url("http://ecma.bdimg.com/public03/imageplus/logo.png") no-repeat; background-position: 0 -17px; width: 16px; height: 16px }
.imageplus-append-nova-txt-ue2 .imageplus-ad-logo { position: absolute; left: 0; bottom: 0; overflow: hidden; z-index: 12; background: url("http://ecma.bdimg.com/public03/imageplus/logo.png") no-repeat; background-position: 0 0; width: 34px; height: 16px }
.imageplus-append { float: none; margin: 0; padding: 0; border: 0; overflow: hidden; visibility: visible; text-align: left; background: transparent; position: relative; text-indent: 0; display: inline-block }
.imageplus-append div { float: none; margin: 0; padding: 0; border: 0; overflow: hidden; position: static; display: block; visibility: visible; text-align: left; background: transparent; font-family: Microsoft YaHei; line-height: normal }
.imageplus-append a,.imageplus-append img,.imageplus-append span { float: none; margin: 0; padding: 0; border: 0; overflow: visible; position: static; display: inline; visibility: visible; text-align: left; background: transparent; font-family: Microsoft YaHei; line-height: normal }
然后我们再把 Trees 与 Stones 打包成 assetbundle 文件,如图:
从图中我们可以看出 Trees(包括 Stamp7 与 Stamp9 两个预设文件)的大小差不多是 Stamp7 与 Stamp9 大小的一半,这是因为 Stamp7 与 Stamp9 材质相同,在打包的时候,共享一份材质,所以材质只有一份。
下面我们给 Stamp7 附加 R1_Column1 的材质,如图:
然后我们再打包 Stamp7 文件,如图:
从下图中,我们可以看到 Stamp7_1 的文件大小比 R1_Column1 与 Stamp7 都要大,因为 Stamp7_1 包括了 R1_Column1 与 Stamp7 的材质。
然后我们再把 Trees 文件重新打包,从下图中我们依然能发现 Trees 文件也变大了,因为 Trees 文件也包括了 R1_Column1 的材质文件。
总结:到这儿我们可以对预设的注意事项有一些了解了,那就是尽量把材质相同的预设放在一起打包
Unity3D 预设打包的注意事项的更多相关文章
- installshield 32位打包和64位打包的注意事项
原文:installshield 32位打包和64位打包的注意事项 32/64位问题要把握几点:1. 明确你的产品是否需要区分32/64位2. 明确你的产品中是否有32/64位的服务注册3. 了解In ...
- Unity3D安卓打包
Unity3D安卓打包须知: 最近在接触Unity3D,在打包安卓时,出现了一些问题,在这里写出来跟大家分享: 首先需要安装jdk和android-sdk,安装方法略 Jdk的目录结构如下: andr ...
- Unity3D安卓打包参数配置与兼容性的关系分析
前言 在使用Unity3D工程导出安卓安装包的时候,往往会遇到兼容性的问题,针对某些机型,要么无法打开游戏,要么会出现卡机的现象.面对这种情况,我们可以调节相关的参数来提高兼容性. 为了了解在打包时候 ...
- unity3d assetbundle打包策略
由于assetbundle打包存在依赖的问题,所有资源要进行合理的分包 零.代码 代码都放在本地,包括NGUI等插件的代码.shader代码(内置的shader无需打包,而自定义的shader还是需要 ...
- unity3d 资源打包加密 整理
资源打包脚本,放到Assets\Editor 文件夹下 using UnityEngine; using System.Collections; using UnityEditor; using Sy ...
- Unity3D 程序打包报错(程序是连接数据库进行处理的)
打包这个Unity3D的程序时出现错误(程序是由XML数据改成连接数据库): ArgumentException: The Assembly System.Configuration is refer ...
- 改造的unity3d文件打包脚本
ExportAssetBundles.rar // C# Example // Builds an asset bundle from the selected objects in the proj ...
- 跟我从零基础学习Unity3D开发--U3d脚本注意事项及两个基本函数的简单介绍
经过上一篇的学习,我相信开发环境您已经搭好了,如果还没有搭好可以百度一下. 今天主要讲的有以下几点: 第一:Unity3D中的C#脚本与.net中的C#写法的区别 1.Unity3D C#脚本不支持命 ...
- 使用maven打包的注意事项
maven编译项目的时候,默认使用的GBK,而目前大部分代码都使用的UTF-8的方式,所以这时候打出来的包容易出现乱码. 解决方式: <!-- compiler插件, 设定JDK版本 --> ...
随机推荐
- javascript函数调用的各种方法!!
在JavaScript中一共有下面4种调用方式: (1) 基本函数调用 (2)方法调用 (3)构造器调用 (4)通过call()和apply()进行调用 1. 基本函数调用 普通函数调用模式,如: J ...
- js事件浅析
js中关于DOM的操作很多,因此js事件机制也就尤为重要. 事件绑定形式: 一. 内联形式 耦合度高,不利于维护 <button onclick="alert('你点击了这个按钮'); ...
- HTML5标签
可以进行省略的标签 不允许写结束标记的标签:area(定义图像映射中的区域).base(为页面上的所有链接规定默认地址或默认目标).br.col(为表格中一个或多个列定义属性值).embed(定义嵌入 ...
- JavaScript区分click事件和mousedown(mouseup、mousemove)方法
在前端开发工作中,会遇到这样问题:针对同一个dom元素,即希望为它绑定click事件,又想该元素可以允许拖拽的效果.而使用拖拽的效果,我们一般就会用到mousedown,mousemove和mouse ...
- ReactiveCocoa代码实践之-更多思考
三.ReactiveCocoa代码实践之-更多思考 1. RACObserve()宏形参写法的区别 之前写代码考虑过 RACObserve(self.timeLabel , text) 和 RACOb ...
- 如何将github上的 lib fork之后通过podfile 改变更新源到自己fork的地址
解决办法: http://stackoverflow.com/questions/20936885/cocoapods-and-github-forks 就是fork完后,提交更改到自己的github ...
- Android开发的小技巧,在Android Studio中使用Designtime Layout Attributes
在编写xml文件时,为了预览效果,经常会使用默认填上一些内容,比如TextView时,随便写上一个text <TextView ... android:text="Name:" ...
- 数据仓库之SSIS开发
1.从cdc捕获到数据以后, 连接ssis进行执行数据的抽取以及转换工作,把需要的数据导入到数据仓库, 并且做好对应的日志记录表.现在先说一下比较重要的. 选择参数化设置数据连接, 以方便后面的配置. ...
- C#实现在图片上斜着写字
最近公司要搞微信活动页面,要实现图片上可以写自己名字的功能,于是就查了一下怎么实现,下面贴一下代码备忘,希望大家也能用到: 我是在控制台应用程序里进行试验的. using (Image bitmap ...
- CMS本质上是什么
2015-121.数据可以任意取和构造,结构也很自由,不一定是“站点-栏目-文章-评论”.2.主要用于显示,前台不产生数据(评论.浏览次数除外).3.在模版进行循环.判断,也比后台写代码要方便很多很多 ...