unity3d,资源过多的话。可以压缩成一个资源包。加载出来后。可以解压。找到自己需要的资源

就想.net网站。很多图标都是放一个大图片上。而不是一个图标就是一个图片

因为是在项目编辑时候给资源打包。并不是项目运行。所以要用到Editor。untiy编辑类,脚本放到Editor文件夹中

 using UnityEngine;
using System.Collections;
using UnityEditor;
public class AsssetBunlder
{
[MenuItem("Custom/SayHello")]
static void SayHello()
{
Debug.Log("hello");
} [MenuItem("Custom/CreateBundle")]
static void CreateBoundle()
{
/*
* Selection类,在编辑状态下,获取选中的对象引用
*/
Object[] objs = Selection.GetFiltered(typeof(object), SelectionMode.DeepAssets); string path = string.Empty; foreach (Object ojb in objs)
{
path = Application.streamingAssetsPath + "/" + ojb.name + ".unity3d";
//创建AssetBunlder
BuildPipeline.BuildAssetBundle(ojb, null, path); //BuildTarget.Android :不同平台打包路径不同
//BuildPipeline.BuildAssetBundle(ojb, null, path, BuildAssetBundleOptions.CollectDependencies, BuildTarget.Android);
}
//自动刷新
AssetDatabase.Refresh();
} [MenuItem("Custom/CreateAllBundle")]
static void CreateAllBoundle()
{
/*
* Selection类,在编辑状态下,获取选中的对象引用
*/
Object[] objs = Selection.GetFiltered(typeof(object), SelectionMode.DeepAssets); string path = string.Empty;
path = Application.streamingAssetsPath + "/All.assetbundle";
//创建AssetBunlder
BuildPipeline.BuildAssetBundle(null, objs, path); //自动刷新
AssetDatabase.Refresh();
} //场景打包
[MenuItem("Custom/StreamBundle")]
static void StreamBundleScene()
{
//要压缩的场景位置
string[] leves = { "Assets/Scene/Demo2.unity" }; //压缩后。资源保存的位置
string path = Application.streamingAssetsPath + @"/Test.assetsbundle"; /*
BuildAdditionalStreamedScenes:以流的方式打包场景
* StandaloneWindows64:在window64位电脑下打包
*/
BuildPipeline.BuildPlayer(leves, path, BuildTarget.StandaloneWindows64, BuildOptions.BuildAdditionalStreamedScenes); } }

单击菜单。会出现你刚写的菜单选项

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPMAAACPCAIAAACgd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khmbuthk41vT5yKc7DmTPcNOAFSE8P02sU/CoHHhdHhrAbYUvjV9vsLJnjvZyK1H4z0Vru+1iR01GKBTzL4DGN+aPgfhZM+H7MnJSWTOnXXanJyc1yb2Gbaoz/BvMuBb0+cinOx5kz05OflSuOAsc93EPk+y8a3pcxBO9pzJRpZDJidRIMxM9jw2sS9kzv6Zbk1/qXCy50w2JooIQ4Daf/69N7HPiWyU8K3pLxdO9jzIxvUTEk42TnZ0CicbJzs6hZONkx2dwsnGyY5O4WTjZEencLJxsqNT0UM2LlzThZONKzr10yYbF65Z9FMle4rX7bq1cuv5FfFHX1+3+7VV25et2ob7Z+7X1+1eEX905dbz63bdivsJk737zuodV377wWcr4o++ufHQmxsP4v6Ze0X80d9+8NnqHVfW7b79EyY79uOv1u5KWr3jysqt59/ZchY37pVbz6/ecWXtrqTYj79aIF0/Jtlxe+7FfvzVut231+26tXZXEm7c63bdWrf7TuzHXy1wwv6xyQ7xHbfnXixu3HvuQTC8Eq6WANm4cf8AxsnGHZ3GycYdncbJxh2dxsnGHZ3GycYdncbJxh2dxsnGHZ3GycYdnf7/zQwrm9YbvgEAAAAASUVORK5CYII=" alt="" />

单击不同的选项就可以根据不同的资源打包了

当读取资源前必须解压

 using UnityEngine;
using System.Collections; public class AssetBoundleContorller : MonoBehaviour
{ /*
* streamingAssetsPath路径。在pc和Andoid,phone中是不同的
* 所以要用预处理(#if #end if)
*/ // public static string RUL;
//#if UNIYT_ANDROID
// "jar:file://"+ Application.dataPath+@"/assets";
//#elif UNITY_IPHONE
// "";
//#endif //#if UNITY_EDITOR
// string filepath = Application.dataPath + "/StreamingAssets" + "/my.xml";
//#elif UNITY_IPHONE
// string filepath = Application.dataPath +"/Raw"+"/my.xml";
//#elif UNITY_ANDROID
// string filepath = "jar:file://" + Application.dataPath + "!/assets/"+"/my.xml;
//#else //#endif // public static string RUL =
//#if UNITY_IPHONE
// string filepath = Application.dataPath +"/assets";
//#elif UNITY_ANDROID
// "jar:file://" + Application.dataPath + "/assets/";
//#else
// Application.streamingAssetsPath + @"/Sphere.unity3d";
//#endif string filepath = string.Empty;
void Awake()
{
#if UNITY_ANDROID
filepath = "jar:file://" + Application.dataPath +@"/assets";
#endif #if UNITY_IPHONE
filepath = "Application.dataPath +@"/Raw";
#endif #if UNITY_STANDALONE_WIN
filepath = @"file://" + Application.streamingAssetsPath + @"/assets";
#endif
} // Use this for initialization
void Start()
{
//1:拿到我们的Assetboundle //string path = @"file://" + Application.streamingAssetsPath + "/Sphere.unity3d"; //StartCoroutine(GetAssetboundle(path)); string path = @"file://" + Application.streamingAssetsPath + "/all.assetbundle";
StartCoroutine(GetAssetboundle(path, "Sphere"));
} /// <summary>
/// 加载一个资源包
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
IEnumerator GetAssetboundle(string path)
{
//没有缓存
WWW www = new WWW(path); //缓存机制,缓存在 硬盘中 5代码版本号,每次缓存都会加1
WWW www1 = WWW.LoadFromCacheOrDownload(path, ); yield return www;
//2:解压并实例化出来
//www.assetBundl返回的是加载AssetBundle压缩文件
//www.assetBundle.mainAsset:解压获取到物体
Instantiate(www.assetBundle.mainAsset); //销毁assetBundle的内存
www.assetBundle.Unload(false);
} /// <summary>
/// 很多资源打包在一起,根据名称找到相应的资源
/// </summary>
/// <param name="path"></param>
/// <param name="name"></param>
/// <returns></returns>
IEnumerator GetAssetboundle(string path, string name)
{
WWW www = new WWW(path);
yield return www; //查看资源里面所以的子资源
//www.assetBundle.LoadAll; //Load 根据名字加载资源
Instantiate(www.assetBundle.Load(name));
} // Update is called once per frame
void Update()
{
//加载场景
if (Input.GetMouseButtonDown())
{
string path = @"file://" + Application.streamingAssetsPath + "/Test.assetsbundle";
StartCoroutine(LoadScene(path, "Demo2"));
}
} /// <summary>
///
/// </summary>
/// <param name="path"></param>
/// <param name="name">打包场景前的scene名称</param>
/// <returns></returns>
IEnumerator LoadScene(string path, string name)
{
WWW www = new WWW(path);
yield return www; //使用之前必须要解压assetbundle
AssetBundle bundle = www.assetBundle; //加载场景
Application.LoadLevel(name); www.assetBundle.Unload(false); }
}

对于不同平台打包路径是不同的。具体看

http://docs.unity3d.com/Manual/PlatformDependentCompilation.html

http://www.taidous.com/article-417-1.html

http://unity3d.9tech.cn/jiaocheng/2013/0621/32651.html

AsssetBunlder打包的更多相关文章

  1. Android Studio 多个编译环境配置 多渠道打包 APK输出配置

    看完这篇你学到什么: 熟悉gradle的构建配置 熟悉代码构建环境的目录结构,你知道的不仅仅是只有src/main 开发.生成环境等等环境可以任意切换打包 多渠道打包 APK输出文件配置 需求 一般我 ...

  2. 【原创分享·支付宝支付】HBuilder打包APP调用支付宝客户端支付

    前言 最近有点空余时间,所以,就研究了一下APP支付.前面很早就搞完APP的微信支付了,但是由于时间上和应用上的情况,支付宝一直没空去研究.然后等我空了的时候,发现支付宝居然升级了支付逻辑,虽然目前还 ...

  3. 细说前端自动化打包工具--webpack

    背景 记得2004年的时候,互联网开发就是做网页,那时也没有前端和后端的区分,有时一个网站就是一些纯静态的html,通过链接组织在一起.用过Dreamweaver的都知道,做网页就像用word编辑文档 ...

  4. .NET Core 系列5 :使用 Nuget打包类库

    NuGet是个开源项目,项目包括 NuGet VS插件/NuGet Explorer/NuGetServer/NuGet命令行等项目,.NET Core项目完全使用Nuget 管理组件之间的依赖关系, ...

  5. Node-Webkit打包

    1.node-webkit是什么? NW.js is an app runtime based on Chromium and node.js. You can write native apps i ...

  6. Gradle 实现 Android 多渠道定制化打包

    Gradle 实现 Android 多渠道定制化打包 版权声明:本文为博主原创文章,未经博主允许不得转载. 最近在项目中遇到需要实现 Apk 多渠道.定制化打包, Google .百度查找了一些资料, ...

  7. 【踩坑速记】开源日历控件,顺便全面解析开源库打包发布到Bintray/Jcenter全过程(新),让开源更简单~

    一.写在前面 自使用android studio开始,就被它独特的依赖方式:compile 'com.android.support:appcompat-v7:25.0.1'所深深吸引,自从有了它,麻 ...

  8. 4.Android 打包时出现的Android Export aborted because fatal error were founds [closed]

    Android 程序开发完成后,如果要发布到互联网上供别人使用,就需要将自己的程序打包成Android 安装包文件(Android Package,APK),其扩展名为.apk.使用run as 也能 ...

  9. 初学seaJs模块化开发,利用grunt打包,减少http请求

    原文地址:初学seaJs模块化开发,利用grunt打包,减少http请求 未压缩合并的演示地址:demo2 学习seaJs的模块化开发,适合对seajs基础有所了解的同学看,目录结构 js — —di ...

随机推荐

  1. .NET Core 2.0 单元测试中初识 IOptionsMonitor<T>

    在针对下面设置 CookieAuthenticationOptions 的扩展方法写单元测试时遇到了问题. public static IServiceCollection AddCnblogsAut ...

  2. hbase 的一些坑

    1)如果你是要远程调用api,  除了依赖包.还要要zookeeper 节点的master,   配置:C:\Windows\System32\drivers\etc\hosts    master. ...

  3. [No0000FB]C# 命名空间(Namespace)

    命名空间的设计目的是提供一种让一组名称与其他名称分隔开的方式.在一个命名空间中声明的类的名称与另一个命名空间中声明的相同的类的名称不冲突. 定义命名空间 命名空间的定义是以关键字 namespace  ...

  4. 【紫书】Ordering Tasks UVA - 10305 拓扑排序:dfs到底再输出。

    题意:给你一些任务1~n,给你m个数对(u,v)代表做完u才能做v 让你给出一个做完这些任务的合理顺序. 题解:拓扑排序版题 dfs到底再压入栈. #define _CRT_SECURE_NO_WAR ...

  5. express工程的优化和请求参数的处理

    1.让工程自动刷新 在Express的默认工程中,ejs, jade等模板的改变会立刻被渲染到浏览器中,但是js的改变不能立即刷新.这时候我们要用到一些自动刷新工具, 如 nodemon, super ...

  6. Exactly-Once 投递语义

    小结: 1.Exactly-Once 是指发送到消息系统的消息只能被消费端处理且仅处理一次,即使生产端重试消息发送导致某消息重复投递,该消息也在消费端也只被消费一次. 消息队列 RocketMQ &g ...

  7. vulnerability test

    vegas ---go--https://zhuanlan.zhihu.com/p/21826478 locust---python jmeter--java---http://www.cnblogs ...

  8. 约数,gcd,exgcd.

    很多题都是要求出什么最大公约数或者最小公倍数什么的,也有一些题目是和约数个数有关的,所以需要总结一下. 首先最大公约数和最小公倍数怎么求呢? 当然是观察法了,对于一些很聪明的孩纸他们一般随便一看就秒出 ...

  9. Transparent HugePages(透明大页)

    Transparent HugePages(透明大页) 1. 介绍 从RedHat6, RedHat7, OL6, OL7 SLES11 and UEK2 kernels开始,透明大页默认是被开启的以 ...

  10. ORACLE监听配置及测试实验(2)

    实验四 在tnsname.ora里添加默认监听代号 [oracle@oracle01 admin]$ vi tnsnames.ora 添加一行 PORT1528=(ADDRESS = (PROTOCO ...