unity3d打包apk怎么把外部资源打包成资源包

unity3d 资源打包加密
发布时间: 10:32:16
资源打包脚本,放到Assets\Editor 文件夹下
using UnityE
using System.C
using UnityE
using System.IO;
public class assetPack : Editor
[MenuItem("Custom Editor/Build AssetBundle From Selection - Track dependencies")]
static void ExportResource2()
// Bring up save panel
string path = EditorUtility.SaveFilePanel("Save Resource", "", "New Resource", "unity3d");
if (path.Length != 0)
// Build the resource file from the active selection.
Object[] selection = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);
BuildPipeline.BuildAssetBundle(Selection.activeObject, selection, path,
BuildAssetBundleOptions.CollectDependencies | pleteAssets);
Selection.objects =
[MenuItem("Custom Editor/Build AssetBundle Complited
static void ExportResource5()
// Bring up save panel
string path = EditorUtility.SaveFilePanel("Save Resource", "", "New Resource", "unity3d");
if (path.Length != 0)
// Build the resource file from the active selection.
Object[] selection = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);
BuildPipeline.BuildAssetBundle(Selection.activeObject, selection, path,
BuildAssetBundleOptions.CollectDependencies | pleteAssets, BuildTarget.Standalone);
Selection.objects =
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.ReadWrite);
byte[] buff = new byte[fs.Length];
fs.Read(buff, 0, (int)fs.Length);
string password = "shanghaichaolan";
packXor(buff,buff.Length,password);
Debug.Log("filelength:"+ buff.Length);
fs.Close();
File.Delete(path);
string BinPath = path.Substring(0, path.LastIndexOf('.')) + ".bytes";
FileStream cfs = new FileStream(BinPath,FileMode.Create);
cfs.Write(buff, 0, buff.Length);
Debug.Log("filelength:" + buff.Length);
cfs.Close();
[MenuItem("Custom Editor/Save Scene2")]
static void ExportResource()
// Bring up save panel
string path = EditorUtility.SaveFilePanel("Save Resource", "", "New Resource", "unity3d");
if (path.Length != 0)
// Build the resource file from the active selection.
Object[] selection = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);
BuildPipeline.BuildAssetBundle(Selection.activeObject, selection, path,
BuildAssetBundleOptions.CollectDependencies | pleteAssets);
Selection.objects =
[MenuItem("Custom Editor/Make unity3d file to bytes file")]
static void ExportResourceNoTrackSS()
string path = EditorUtility.SaveFilePanel("Save Resource", "", "New Resource", "unity3d");
if (path.Length != 0)
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.ReadWrite);
byte[] buff = new byte[fs.Length];
fs.Read(buff, 0, (int)fs.Length);
string password = "shanghaichaolan";
packXor(buff, buff.Length, password);
Debug.Log("filelength:" + buff.Length);
fs.Close();
File.Delete(path);
string BinPath = path.Substring(0, path.LastIndexOf('.')) + ".bytes";
FileStream cfs = new FileStream(BinPath, FileMode.Create);
cfs.Write(buff, 0, buff.Length);
Debug.Log("filelength:" + buff.Length);
cfs.Close();
static void packXor(byte[] _data, int _len, string _pstr)
int length = _
int strCount = 0;
for (int i = 0; i & ++i)
if (strCount &= _pstr.Length)
strCount = 0;
_data[i] ^= (byte)_pstr[strCount++];
&菜单上就会出现两个, 把要打包的资源做成Prefab,选中资源,然后菜单Custom Editor/Save Scene2& 输入名字
新生成的文件,再选中新生成的文件,点击菜单Custom Editor/Make unity3d file to bytes file&& 输入名字
又生成了一个文件,再点击这个文件,菜单Custom Editor/Save Scene2& ,这样就打包加密好了
using UnityE
using System.C
public class loadnew : MonoBehaviour
private string BundleURL;
private string AssetN
void Start()
//StartCoroutine(loadScenee());
StartCoroutine(LoadResource());
IEnumerator loadScenee()
path = "file://" + Application.dataPath + "/" + filename + ".unity3d";
Debug.Log(path);
WWW www = new WWW(path);
AssetBundle bundle = www.assetB
//GameObject go = bundle.Load("gCube",typeof(GameObject)) as GameO
GameObject ObjScene = Instantiate(www.assetBundle.mainAsset) as GameO
bundle.Unload(false);
IEnumerator LoadResource()
BundleURL = "file://" + Application.dataPath + "/" + filename + ".unity3d";
Debug.Log("path:" + BundleURL);
WWW m_Download = new WWW(BundleURL);
yield return m_D
if (m_Download.error != null)
Debug.LogError(m_Download.error);
Debug.LogError("Warning errow: " + "NewScene");
TextAsset txt = m_Download.assetBundle.Load(filename, typeof(TextAsset)) as TextA
byte[] data = txt.
byte[] decryptedData = Decryption(data);
Debug.Log("decryptedData length:" + decryptedData.Length);
StartCoroutine(LoadBundle(decryptedData));
IEnumerator LoadBundle(byte[] decryptedData)
AssetBundleCreateRequest acr = AssetBundle.CreateFromMemory(decryptedData);
AssetBundle bundle = acr.assetB
Instantiate(bundle.mainAsset);
byte[] Decryption(byte[] data)
byte[] tmp = new byte[data.Length];
for (int i = 0; i & data.L i++)
tmp[i] = data[i];
shanghaichaolan
string password ="shanghaichaolan";
packXor(tmp,tmp.Length,password);
static void packXor(byte[] _data, int _len, string _pstr)
int length = _
int strCount = 0;
for (int i = 0; i & ++i)
if (strCount &= _pstr.Length)
strCount = 0;
_data[i] ^= (byte)_pstr[strCount++];
void update()
&加载加密和不加密的资源
来源:/dragon2012/p/4087548.htmldisunity解包出来的资源怎么打包回去?【unity3d吧】_百度贴吧
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&签到排名:今日本吧第个签到,本吧因你更精彩,明天继续来努力!
本吧签到人数:0成为超级会员,使用一键签到本月漏签0次!成为超级会员,赠送8张补签卡连续签到:天&&累计签到:天超级会员单次开通12个月以上,赠送连续签到卡3张
关注:78,331贴子:
disunity解包出来的资源怎么打包回去?收藏
求解,解决了发支付宝。我的QQ.求解决
51CTO学院11年行业品牌,1400万用户选择,中国专业IT技能学习平台,unity能做什么.通过在线学习的方式,帮助广大技术人员实现技能提升,高薪就业的职业梦想,unity能做什么.
求解决,,,,,,
disunity解包出来的资源怎么打包回去?
登录百度帐号推荐应用unity3d远程加载资源模型到本地并加载(一)打包资源 - CSDN博客
unity3d远程加载资源模型到本地并加载(一)打包资源
由于模型放在远程服务器,fbx格式是不能加载的所以可以做成预设或是AssetBundle格式进行远程加载。首先打包AssetBundle资源!在unity资源文件夹下新建一下一个Editor文件夹 下方一个脚本代码如下!(代码可复制!!!)
using UnityE
using System.C
using UnityE
public class ExportAssetBundles : MonoBehaviour {
//在Unity编辑器中添加菜单
[MenuItem(“AssetBundle/打包选中的文件”)]
static void Export()
// 打开保存面板,获得用户选择的路径
string path = EditorUtility.SaveFilePanel(“保存文件”, “”, “模型”, “assetbundle”);
if (path.Length != 0)
// 选择的要保存的对象
Object[] selection = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);
//打包 成AssetBundle
BuildPipeline.BuildAssetBundle(Selection.activeObject, selection, path, BuildAssetBundleOptions.CollectDependencies | pleteAssets, BuildTarget.StandaloneWindows);
本文已收录于以下专栏:
相关文章推荐
将模型资源加载到场景中显示
1.从本地加载
void OnGUI()
if (GUILayout.Button("click"))
原文地址:/thread-.html?_dsign=b3aeb908
游戏开发中需要从服务器上加载一下资源包,场景等,这时就需要...
今天要做一个移动平台的版本控制,先做一个前期的工作,就是从服务器端加载资源,然后读取到本地,再从本地读取资源。这里就以pc平台为例,移动平台也是一样,就是稍微做一点路径上的修改,
下面是不同平台路径的...
using UnityE
using System.C
using System.IO;
public class Resource : MonoBehavio...
各位朋友,大家好,欢迎大家关注我的博客,我是**秦元培**,我的博客地址是[]()。今天想和大家交流的是解析obj模...
由于我们要将模型资源放在远程的服务器端,但如果直接放fbx模型是不可以加载的,所以我们可以将fbx做成预设或者是直接将其打包成assetbundle格式的,然后通过www来加载获取。
1.首先要讲一下...
转载自:/sifenkesi/p/3559924.html
每个需要进行资源管理的类都继承自IAssetManager,该类维护它所使用到的所有资...
用Unity3D制作基于web的网络游戏,不可避免的会用到一个技术-资源动态加载。比如想加载一个大场景的资源,不应该在游戏的开始让用户长时间等待全部资源的加载完毕。应该优先加载用户附近的场景资源,在游...
Unity3D中的资源路径
Application.dataPath
此属性用于返回程序的数据文件所在文件夹的路径。例如在Edi...
最近比较忙,有段时间没写博客拉。最近项目中需要使用HTTP与Socket,雨松MOMO把自己这段时间学习的资料整理一下。有关Socket与HTTP的基础知识MOMO就不赘述拉,不懂得朋友自己谷歌吧。我...
他的最新文章
讲师:宋宝华
讲师:何宇健
您举报文章:
举报原因:
原文地址:
原因补充:
(最多只允许输入30个字)unity3d怎么将外部资源打资源成资源包?
作者:佚名
字体:[ ] 来源:互联网 时间:05-30 14:03:17
unity3d怎么将外部资源打资源成资源包?unity3d中做游戏的时候,经常需要外部资源,如果不讲资源打包带走,程序就没办法运行,该怎么打包呢?请看下文详细教程,需要的朋友可以参考下
当我们开发游戏时,会经常需要到其他工程里的资源,这时候我们就需要将资源打包带走啦
软件名称:unity3d 4.0 附图文安装破解教程软件大小:678MB更新时间:
1、选择好要带走的资源文件夹
2、点击菜单栏中的Asstes选项,选择 export package。
3、然后点击export
4、点击存放资源的位置,默认文件格式为unitypackage。点击确定即可完成。
相关推荐:
大家感兴趣的内容
12345678910
最近更新的内容}

我要回帖

更多关于 unity3d标准资源包 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信