Unity AssetBundle 踩坑记录
Unity AssetBundle 踩坑记录
editor 下选择什么平台的 ab 加载
Material doesn't have a color property '_Color'
UnityEditor.DockArea:OnGUI()
Material doesn't have a float or range property 'PixelSnap'
UnityEditor.DockArea:OnGUI()
因为editor模式下所有的 platform ab 都是可以用的 并且打 android ab 包必须要把platform转换为android
但是自己写的cg shader 如果打成 android ab 在editor 模式下没有OpenGL 2.0 环境会报错
只有打成windows包
但是好像其他 surface shader 是可以的
参考
The asset bundle '' can't be loaded because another asset bundle with the same files are already loaded
create scene assetbundle Scenes/battle/MapEditor/53.unityin _LoadImmediate failed
可能的原因
相同名字 bundle load 加载后
http://forum.unity3d.com/threads/asset-bundle-cant-be-the-same-name.190275
这里经过测试过 发现相同名字不同后缀的单个资源 bundle 是可以的
但是相同名字相同后缀即使路径不同也是不可以的
ab重复加载
解决方法
后期使用asset guid 来给ab命名 ab的asset name path 随意 guid 也行 相对于 asset path 也行
不同机子打包的ab md5 值不同 无语了
打 ab 最好把脚本打进去 有概率会出现看不见的情况
如果在同一个场景对ab做清理对话 会对当时的场景造成当时就材质丢失的情况 就是出现闪一下红色
最好就是弄个东西挡一下 比如ui 或者 弄一个单独加载场景的场景 在挡着的时候进行卸载
load sprite from ab
[MenuItem("Build/Tools/Test")]
public static void TestSceneAssets() {
UnityEngine.Object[] assets =
new UnityEngine.Object[] {
AssetDatabase.LoadAssetAtPath("Assets/Resources/Icon/ectype_chapter/1.png",
typeof(UnityEngine.Object)) };
UnityEngine.Object mainAsset = assets[0];
string savePath =
"f:/assetbundles/windows/"
+ "d4fe2a6e186849f4086398d2ceeb0510"
+ ResourceCommon.assetbundleFileSuffix;
BuildPipeline.BuildAssetBundle(
mainAsset, assets, savePath,
BuildAssetBundleOptions.CollectDependencies
| BuildAssetBundleOptions.CompleteAssets
| BuildAssetBundleOptions.DeterministicAssetBundle,
BuildTarget.StandaloneWindows);
}
mTest6.cs
void OnGUI()
{
if (GUI.Button(new Rect(10, 10, 150, 100), "I am a button")) Test();
}
void Test()
{
TextAsset bundleFile = Resources.Load("d4fe2a6e186849f4086398d2ceeb0510") as TextAsset;
AssetBundle assetBundle = AssetBundle.CreateFromMemoryImmediate(bundleFile.bytes);
Object[] assets = assetBundle.LoadAll();
foreach (Object asset in assets)
{
Debug.Log("loaded asset " + asset.name + " of type " + asset.GetType());
}
}
//loaded asset 1 of type UnityEngine.Texture2D
//loaded asset 1 of type UnityEngine.Sprite
string path = "Assets/NGUI/Examples/Models/Orc/FBX.FBX";
UnityEngine.Object[] assets = new UnityEngine.Object[] {
AssetDatabase.LoadAssetAtPath(path, typeof(UnityEngine.Object)) };
string[] depends = AssetDatabase.GetDependencies(new string[] { path });
foreach (string str in depends)
{
Debug.Log("depency: " + str);
}
//depency: Assets/NGUI/Examples/Models/Orc/FBX@idle.FBX
//depency: Assets/NGUI/Examples/Models/Orc/FBX@idleBreaks.FBX
//depency: Assets/NGUI/Examples/Models/Orc/FBX.FBX
List<string> tmp = new List<string>();
int index = 0;
foreach (Object asset in assets){
Debug.Log("loaded asset " + asset.name + " of type " + asset.GetType());
index++;
tmp.Add(index+"");
}
UnityEngine.Object mainAsset = assets[0];
string savePath =
"f:/assetbundles/windows/"
+ "d4fe2a6e186849f4086398d2ceeb0510"
+ ResourceCommon.assetbundleFileSuffix;
-----1
BuildPipeline.BuildAssetBundle(
mainAsset, assets, savePath,
BuildAssetBundleOptions.CollectDependencies
| BuildAssetBundleOptions.CompleteAssets
| BuildAssetBundleOptions.DeterministicAssetBundle,
BuildTarget.StandaloneWindows); 会收集依赖 比如 fbx@idle 等等
-----2
BuildPipeline.BuildAssetBundleExplicitAssetNames(
assets, tmp.ToArray(), savePath,
BuildAssetBundleOptions.CollectDependencies
| BuildAssetBundleOptions.CompleteAssets
| BuildAssetBundleOptions.DeterministicAssetBundle,
BuildTarget.StandaloneWindows); ///不会收集依赖 比如 fbx@idle 等等
void Test()
{
TextAsset bundleFile = Resources.Load("d4fe2a6e186849f4086398d2ceeb0510") as TextAsset;
AssetBundle assetBundle = AssetBundle.CreateFromMemoryImmediate(bundleFile.bytes);
Object[] assets = assetBundle.LoadAll();
foreach (Object asset in assets)
{
Debug.Log("loaded asset " + asset.name + " of type " + asset.GetType());
}
}
-----1
//loaded asset FBX of type UnityEngine.GameObject
//loaded asset FBX of type UnityEngine.Transform
//loaded asset Orc of type UnityEngine.Mesh
//loaded asset FBX@idle of type UnityEngine.GameObject
//loaded asset FBX@idle of type UnityEngine.Transform
//loaded asset Orc of type UnityEngine.Mesh
//loaded asset idle of type UnityEngine.AnimationClip .etc
------2
//loaded asset FBX of type UnityEngine.GameObject
//loaded asset FBX of type UnityEngine.Transform
从上述实验看 BuildPipeline.BuildAssetBundle 和 BuildPipeline.BuildAssetBundleExplicitAssetNames 不同之处
就在于后者只打包你当前指定的资源,比如 fix 或者 texture2d 下面的 mesh 和 sprite 不会打包进去 ,
并且依赖比如 fbx@idle 也不会打包进去 , 不过这个还好,正好是我们当前的打包策略,依赖由我们自己掌握
这样我们考虑 texture2d 的打包策略和 prefab 的打包策略不一样了 或者 内存中动态生成sprite
参考
load-unity-43-sprites-with-assetbundles
参考
Unite 2014 - New AssetBundle Build System in Unity 5
new-assetbundle-build-system-in-unity-5-0.293975
Unity AssetBundle 踩坑记录的更多相关文章
- 你真的了解字典(Dictionary)吗? C# Memory Cache 踩坑记录 .net 泛型 结构化CSS设计思维 WinForm POST上传与后台接收 高效实用的.NET开源项目 .net 笔试面试总结(3) .net 笔试面试总结(2) 依赖注入 C# RSA 加密 C#与Java AES 加密解密
你真的了解字典(Dictionary)吗? 从一道亲身经历的面试题说起 半年前,我参加我现在所在公司的面试,面试官给了一道题,说有一个Y形的链表,知道起始节点,找出交叉节点.为了便于描述,我把上面 ...
- unionId突然不能获取的踩坑记录
昨天(2016-2-2日),突然发现系统的一个微信接口使用不了了.后来经查发现,是在网页授权获取用户基本信息的时候,unionid获取失败导致的. 在网页授权获取用户基本信息的介绍中(http://m ...
- CentOS7.4安装MySQL踩坑记录
CentOS7.4安装MySQL踩坑记录 time: 2018.3.19 CentOS7.4安装MySQL时网上的文档虽然多但是不靠谱的也多, 可能因为版本与时间的问题, 所以记录下自己踩坑的过程, ...
- ubuntu 下安装docker 踩坑记录
ubuntu 下安装docker 踩坑记录 # Setp : 移除旧版本Docker sudo apt-get remove docker docker-engine docker.io # Step ...
- SpringBoot + Shiro + shiro.ini 的踩坑记录
0.写在前面的话 好久没写博客了,诶,好多时候偷懒直接就抓网上的资料丢笔记里了,也就没有自己提炼,偷懒偷懒.然后最近参加了一个网络课程,要交作业的那种,为了能方便看下其他同学的作业,就写了个爬虫把作业 ...
- google nmt 实验踩坑记录
最近因为要做一个title压缩的任务,所以调研了一些text summary的方法. text summary 一般分为抽取式和生成式两种.前者一般是从原始的文本中抽取出重要的word o ...
- ABP框架踩坑记录
ABP框架踩坑记录 ASP.NET Boilerplate是一个专用于现代Web应用程序的通用应用程序框架. 它使用了你已经熟悉的工具,并根据它们实现最佳实践. 文章目录 使用MySQL 配置User ...
- SpringBoot+SpringSecurity+Thymeleaf认证失败返回错误信息踩坑记录
Spring boot +Spring Security + Thymeleaf认证失败返回错误信息踩坑记录 步入8102年,现在企业开发追求快速,Springboot以多种优秀特性引领潮流,在众多使 ...
- IDFA踩坑记录
IDFA踩坑记录: 1.iOS10.0 以下,即使打开“限制广告跟踪”,依然可以读取idfa: 2.打开“限制广告跟踪”,然后再关闭“限制广告跟踪”,idfa会改变: 3.越狱机器安装开发证书打的包, ...
随机推荐
- html实现点击章节自动调到开头
#转载请联系 原理是用id的值结合a链接实现锚点效果.比较简单,直接放一段代码好了. <!DOCTYPE html> <html lang="en"> &l ...
- hdu 1410(直线与矩形相交)
Intersection Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 13528 Accepted: 3521 Des ...
- Windows+Ubuntu双系统如何设置Windows为第一启动项
在安装双系统的时候,如果先安装的是Windows然后再安装Ubuntu系统,开机时是以Ubuntu的grub来引导Windows的,而且默认进入Ubuntu系统,下面我们介绍如何更改这个默认项,然后让 ...
- 360开源的pika
http://www.360doc.com/content/16/0531/14/13247663_563808424.shtml https://github.com/Qihoo360/pika/b ...
- PHP7中php.ini、php-fpm和www.conf的配置(转)
根据前文 <2015博客升级记(五):CentOS 7.1编译安装PHP7> 的 configure 编译参数设定,安装后的PHP7配置文件所在路径是 /usr/local/php7/et ...
- [BZOJ2049][Sdoi2008]Cave 洞穴勘测 LCT模板
2049: [Sdoi2008]Cave 洞穴勘测 Time Limit: 10 Sec Memory Limit: 259 MBSubmit: 9705 Solved: 4674[Submit] ...
- 转:Laravel 安装指南
Git 介绍 之所以要说 Git,就是因为 Composre 有时需要用到 Git,还是安装上比较好,Composer 暂且不表,先来了解一下 Git 吧(已经安装的童鞋跳过这里,直接看 Compos ...
- 跳转的两种实现方法setInterval和setTimeout
setInterval方法: <html> <head> <meta http-equiv="Content-Type" content=" ...
- 构建ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统
http://www.tuicool.com/articles/NfyqQr 本节主要知识点是easyui 的手风琴加树结构做菜单导航 有园友抱怨原来菜单非常难看,但是基于原有树形无限级别的设计,没有 ...
- 一个LaTeX 中文文档的简单而实用的模板
网上找的一个latex中文模板,感觉很简单,在我机器上有点小问题,完善记录一下. %要运行该模板,LaTex需要安装CJK库以支持汉字. %字体大小为12像素,文档类型为article %如果你要写论 ...