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.越狱机器安装开发证书打的包, ...
随机推荐
- 在什么情况下Java比C++快?
转载 http://www.importnew.com/16056.html
- 关于oracle的sqlplus的另一些小技巧
执行脚本的命令在上一节已经讲过,不再重复. sqlplus user/password@ip:port/servicename @/path/sqltest.sql; sqltest的内容及注释: - ...
- vs2012将项目同步到github
http://www.cnblogs.com/SmallZL/p/3637613.html 大神作品,亲测可用
- hdu6158(圆的反演)
hdu6158 题意 初始有两个圆,按照标号去放圆,问放完 \(n\) 个圆后的总面积. 分析 圆的反演的应用. 参考blog 设反演圆心为 \(O\) 和反演半径 \(R\) 圆的反演的定义: 已知 ...
- 51nod 最长公共子序列问题(动态规划)(LCS)(递归)
最长公共子序列问题 输入 第1行:字符串A 第2行:字符串B (A,B的长度 <= 1000) 输出 输出最长的子序列,如果有多个,随意输出1个. 输入示例 abcicba abdkscab 输 ...
- C++—揭秘大牛博客一些不同凡人的写法
天下之大,无奇不有,C++也是这样,今天小编来盘点几个有意思的代码,看看你认识几个?以后见到之后千万别装不认识. 一.基础篇——不一样的输出 1.cerr 输出 cout和cerr究竟有什么不同?这也 ...
- 闪迪U3利用工具U3-Pwn
闪迪U3利用工具U3-Pwn 闪迪U3是闪迪公司为Sandisk Cruzer系列U盘提供的一个功能.该模块支持数据加密和CD启动功能.U3-Pwn就是针对U3的一个利用工具.渗透测试人员可以通过 ...
- CodeForces - 283E Cow Tennis Tournament
Discription Farmer John is hosting a tennis tournament with his n cows. Each cow has a skill level s ...
- POJ 2482 Stars in Your Window(扫描线+线段树)
[题目链接] http://poj.org/problem?id=2482 [题目大意] 给出一些点的二维坐标和权值,求用一个长H,宽W的矩形能框住的最大权值之和, 在矩形边缘的点不计算在内 [题解] ...
- 【后缀数组】【二分答案】【差分】poj1743 Musical Theme
差分消除加减一个值得影响,貌似r二分上界要设成(n-2)/2?为啥? sa求不可重叠最长重复子串 给定一个字符串,求最长重复子串,这两个子串不能重叠.算法分析:这题比上一题稍复杂一点.先二分答案,把题 ...