unityunity resources 目录打包后可写吗

Unity3D打包后,Resources图片不显示_unity3d吧_百度贴吧
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&签到排名:今日本吧第个签到,本吧因你更精彩,明天继续来努力!
本吧签到人数:0成为超级会员,使用一键签到本月漏签0次!成为超级会员,赠送8张补签卡连续签到:天&&累计签到:天超级会员单次开通12个月以上,赠送连续签到卡3张
关注:56,356贴子:
Unity3D打包后,Resources图片不显示收藏
Unity3D打包后,无论是PC端,还是Android端,Resources目录下的图片不会显示,请问这个怎么解决
unity3d千锋VR培训0元入学,先就业后付款,「申请2周免费试学」.千锋VR培训,0基础快速转行,入学即签订就业协议,「高薪」就业!现在报名立减1000元!
用streamingassets文件夹
我来科普一下,unity会将resources文件夹内的资源打包压缩,所以说,这不是问题,因为这个目录下本来就不显示原资源文件。
你加载的方式对不对?
登录百度帐号推荐应用
为兴趣而生,贴吧更懂你。或用disunity解压出来的resources.assets文件如何打包回去? - 汉化交流 - 扑家吧
用disunity解压出来的resources.assets文件如何打包回去?
我按照网上的教程用disunity将resources.assets转换成了resources文件夹并将里面的文本进行了修改,但之后如何将resources文件夹转换为resources.assets以便能够使用呢?
@
@
这是在干嘛,好厉害的感觉。。。破解psp游戏??路过帮顶。。。
@ 我们都是自己写的脚本
自己写吧,disunity没提供这项功能
@ 这样解压出来的resources有能用的模型还有动画吗?如果可以就太好了,我可以拿来做东西
@
@
意思就是只有自己编程把它编回去吗?能不能提供一下源代码之类的?
目测是unity3d的包,disunity貌似没有此功能,可以通过观察disunity的源码实现。
我也想知道!我想汉化一个游戏,可打包遇到了困难
我也想知道怎么打包回去、、大家有方法吗?我的QQ5132906
请先再回复,如果你还没有账号,请先。这几天一直在研究热更新方案
主要思路是:
1.先将代码打包成dll,然后用unity 打包成assetsbundle,
2.WWW加载进入主程序,
3使用System.Reflection.Assembly来创建程序集,
4.然后通过GetType(className),来获取这个类
5.AddComponent进入主程序,加载的dll就执行起来了。
ExportAssetBundles.cs
//打包工具,该工具是网上找来都。谢谢作者!
public class ExportAssetBundles : MonoBehaviour {
//在Unity编辑器中添加菜单
[MenuItem("Custom Editor/Create AssetBunldes ALL")]
static void ExportResource()
// 打开保存面板,获得用户选择的路径
string path = EditorUtility.SaveFilePanel("Save Resource", "", "New Resource", "assetbundle");
if (path.Length != 0)
// 选择的要保存的对象
Object[] selection = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);
BuildPipeline.BuildAssetBundle(Selection.activeObject, selection, path, BuildAssetBundleOptions.CollectDependencies | pleteAssets, BuildTarget.StandaloneWindows);
1234567891011121314151617181920
//打包工具,该工具是网上找来都。谢谢作者!public class ExportAssetBundles : MonoBehaviour {&&&&&//在Unity编辑器中添加菜单&&&&&&[MenuItem("Custom Editor/Create AssetBunldes ALL")]&&&&static void ExportResource()&&&&{&&&&&&&&// 打开保存面板,获得用户选择的路径&&&&&&&&&&string path = EditorUtility.SaveFilePanel("Save Resource", "", "New Resource", "assetbundle");&&&&&&&&&if (path.Length != 0)&&&&&&&&{&&&&&&&&&&&&// 选择的要保存的对象&&&&&&&&&&&&&&Object[] selection = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);&&&&&&&&&&&&//打包&&&&&&&&&&&&&&BuildPipeline.BuildAssetBundle(Selection.activeObject, selection, path, BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets, BuildTarget.StandaloneWindows);&&&&&&&&&&&&&&}&&&&}&&}
using UnityE
using System.C
using System.R
//代码加载器
public class Index : MonoBehaviour
private WWW
public static WWW uiWWW;
private System.Reflection.A
// Use this for initialization
void Start ()
StartCoroutine(loadScript());
private IEnumerator loadScript()
//加载我的代码资源
www = new WWW("http://localhost/Main.assetbundle");
AssetBundle bundle = www.assetB
TextAsset asset = bundle.Load("Main", typeof(TextAsset)) as TextA
assembly = System.Reflection.Assembly.Load(asset.bytes);
Assembly[] assLis = System.AppDomain.CurrentDomain.GetAssemblies();
System.Type script = assembly.GetType("Main");
gameObject.AddComponent(script);
12345678910111213141516171819202122232425262728293031323334353637
using UnityEngine;using System.Collections;using System.Reflection;&//代码加载器public class Index : MonoBehaviour{&&&&&private WWW www;&&&&&public static WWW uiWWW;&&&&&private System.Reflection.Assembly assembly;& // Use this for initialization void Start () &&&&{&&&&&&&&StartCoroutine(loadScript()); }&&&&&private IEnumerator loadScript()&&&&{&&&&&&&&//加载我的代码资源&&&&&&&&www = new WWW("http://localhost/Main.assetbundle");&&&&&&&&yield return www;&&&&&&&&&AssetBundle bundle = www.assetBundle;&&&&&&&&TextAsset asset = bundle.Load("Main", typeof(TextAsset)) as TextAsset;&&&&&&&&assembly = System.Reflection.Assembly.Load(asset.bytes);&&&&&&&&&Assembly[] assLis = System.AppDomain.CurrentDomain.GetAssemblies();&&&&&&&&&System.Type script = assembly.GetType("Main");&&&&&&&&&gameObject.AddComponent(script);&&&&}}
因为在加载的时候遇见安全沙箱问题,所以我将这个策略文件记录下来,方便下次复制粘贴
crossdomain.xml
&?xml version="1.0"?&
&cross-domain-policy&
&site-control permitted-cross-domain-policies=”master-only” /&
&allow-access-from domain="" /&
&allow-access-from domain="*"/&
&/cross-domain-policy&
&?xml version="1.0"?&&cross-domain-policy&&site-control permitted-cross-domain-policies=”master-only” /&&allow-access-from domain="" /&&allow-access-from domain="*"/&&/cross-domain-policy&
本地调试程序时解决跨域问题的方法:
Edit-&Project Settings-&Eidtor
刚开始的时候想使用序列化来存储一些数据,但是后来却连一个很简单的类序列化dll里面都没法获得
官方对象序列号
[MenuItem("Custom Editor/WriteSpriteData")]
static void FileWriteSpriteData()
TextAsset textasset = AssetDatabase.LoadAssetAtPath("Assets/Resources/Packer/Packer.txt", typeof(TextAsset)) as TextA
Atlas atlas = ScriptableObject.CreateInstance&Atlas&();
//Json其实是NGUIJson这个类,我只是把他提出来。改了个名字
atlas.mList = Json.LoadSpriteData(textasset as TextAsset);
if (atlas.mList == null)
string path = "Assets/Resources/Packer/Packer.asset";
AssetDatabase.CreateAsset(atlas, path);
//Atlas是一个只有一个mList属性都类 mList = new List&UISpriteData&();
Object o = AssetDatabase.LoadAssetAtPath(path, typeof(Atlas));
Object texture = AssetDatabase.LoadAssetAtPath("Assets/Resources/Packer/Packer.mat", typeof(Material));
Object[] t = {texture};
BuildPipeline.BuildAssetBundle(o, t, "Assets/Resources/Packer/Packer.assetbundle");
//AssetDatabase.DeleteAsset(path);
12345678910111213141516171819202122232425
[MenuItem("Custom Editor/WriteSpriteData")]&&&&static void FileWriteSpriteData()&&&&{&&&&&&&&TextAsset textasset = AssetDatabase.LoadAssetAtPath("Assets/Resources/Packer/Packer.txt", typeof(TextAsset)) as TextAsset;&&&&&&&&&Atlas atlas = ScriptableObject.CreateInstance&Atlas&();//Json其实是NGUIJson这个类,我只是把他提出来。改了个名字&&&&&&&&atlas.mList = Json.LoadSpriteData(textasset as TextAsset);&&&&&&&&&if (atlas.mList == null)&&&&&&&&&&&&return;&&&&&&&&&string path = "Assets/Resources/Packer/Packer.asset";&&&&&&&&&AssetDatabase.CreateAsset(atlas, path);//Atlas是一个只有一个mList属性都类 mList = new List&UISpriteData&();&&&&&&&&Object o = AssetDatabase.LoadAssetAtPath(path, typeof(Atlas));&&&&&&&&Object texture = AssetDatabase.LoadAssetAtPath("Assets/Resources/Packer/Packer.mat", typeof(Material));&&&&&&&&&Object[] t = {texture};&&&&&&&&&BuildPipeline.BuildAssetBundle(o, t, "Assets/Resources/Packer/Packer.assetbundle");&&&&&&&&&&&&&&&&//AssetDatabase.DeleteAsset(path);&&&&}
这是使用序列化数据的加载方式,在不用反射的情况下,下面代码加载能够成功,但是使用了反射,下面的代码就加载不成功了。这个问题我也很费解,暂时我没办法解决
读取序列化对象
IEnumerator LoadAtlas()
www = new WWW("http://localhost/Packer.assetbundle");
//WoodenAtlas.assetbundle
//Packer.assetbundle
//用来断点都时候看看里面所包含都数据
Object[] os = www.assetBundle.LoadAll();
Material mete = www.assetBundle.Load("Packer", typeof(Material)) as M
Atlas atlas = www.assetBundle.mainAsset as A
GameObject go = new GameObject("UIAtlas");
UIAtlas uiatlas = go.AddComponent&UIAtlas&();
uiatlas.spriteMaterial =
uiatlas.spriteList = atlas.mL
GameObject sprite = new GameObject("Sprite");
UISprite ui = NGUITools.AddChild&UISprite&(sprite);
ui.atlas =
ui.spriteName = "dynamite";
Debug.Log("Load");
www.assetBundle.Unload(false);
www.Dispose();
1234567891011121314151617181920212223242526
IEnumerator LoadAtlas()&&&&{&&&&&&&&www = new WWW("http://localhost/Packer.assetbundle");&&&&&&&&//WoodenAtlas.assetbundle&&&&&&&&//Packer.assetbundle&&&&&&&&yield return www;//用来断点都时候看看里面所包含都数据&&&&&&&&Object[] os = www.assetBundle.LoadAll();&&&&&&&&&Material mete = www.assetBundle.Load("Packer", typeof(Material)) as Material;&&&&&&&&Atlas atlas = www.assetBundle.mainAsset as Atlas;&&&&&&&&GameObject go = new GameObject("UIAtlas");&&&&&&&&UIAtlas uiatlas = go.AddComponent&UIAtlas&();&&&&&&&&uiatlas.spriteMaterial = mete;&&&&&&&&uiatlas.spriteList = atlas.mList;&&&&&&&&&GameObject sprite = new GameObject("Sprite");&&&&&&&&UISprite ui = NGUITools.AddChild&UISprite&(sprite);&&&&&&&&ui.atlas = uiatlas;&&&&&&&&ui.spriteName = "dynamite";&&&&&&&&Debug.Log("Load");&&&&&&&&&www.assetBundle.Unload(false);&&&&&&&&www.Dispose();&&&&&&&&&&&&}
因为要看一下代码的执行效率,所以我寻找到了这个类。感觉还可以。使用josn数据,mat文件创建一个UIAtlas的时间大概是30毫秒左右。
System.Diagnostics.S
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
Thread.Sleep(10000);
stopWatch.Stop();
System.Diagnostics.Stopwatch;Stopwatch stopWatch = new Stopwatch();stopWatch.Start();Thread.Sleep(10000);stopWatch.Stop();
我使用没有任何Unity环境以外代码来实现壳的制作(我们暂且将其称为Index,其实他就是上面的Index类,代码少得可怜。)
然后主程序是在另一个Unity项目中(这个项目在发布的时候打包成Main.dll)
Main.dll项目通过上面的Index来加载,然后添加到一个GameObject上,主程序的Awake()方法就会执行(Awake是整个程序的主入口)
这个时候所有的资源加载都会在Main.dll里面完成。
在这个过程中,遇到了一个比较麻烦的问题就是,我打包的一些UIAtlas.prefab文件上的UIAtlas这个类,无法找到。
这让我有一些无法理解,因为NGUI的代码已经打包进入了Main.dll,那么为什么我加载prefab的时候,却找不到UIAtlas这个类呢?
最后我只能动态的制作UIAtlas对象来完成这样工作。
那么这样的话,以后做界面,做任何prefab都不能绑定脚本了。都只能加载到内存中动态AddComponent了。这样界面也得用配置文件了。
不过对于我这种从页游转过来的程序,这到不是问题,我有现成的界面编辑器(我博客里有),直接生成XML在游戏中进行组装了。对于能够热更新来说,这点麻烦,其实应该不算麻烦了。
动态生成UIAtlas后,创建了几个Sprite、Button,基本的功能都已经实现,说明这个解决方案是可行的。接下来我将把这个方案运用到我的项目中,更加全面的去实验一下。
这样设计的优点:
1、对IOS的打包也是比较方便。打包IOS 直接拿Main项目打包就可以了。因为不需要热更新了。把代码打包在本地就行了。
2、打包Android项目的时候发布apk只需要发布Index,项目发布版本和没写代码一样大,想到这里我想吐槽一下,Unity就算不写任何代码,发布一个apk也得有7M左右。这也太大了点吧。我可啥都没做啊。
1、哪位大神能给我说说上面我遇到的那个问题,为什么找不到绑定在prefab上的类呢?这是程序集的问题么?哎,刚转C#的人伤不起。
[…] 3、这也是最主要的,如果你看过我上一篇文章《Unity代码热更新解决方案测试结果总结》你就会知道我为什么要这么做了,都是泪啊。。 […]Unity官方公布热更新方案性能对比浅析
Unity应用的iOS热更新
作者:丁治宇
Unity TechnologiesChina
? 什么是热更新
? 为何要热更新
? 如何在iOS 上对Unity 应用进行热更新
? 支持Unity iOS 热更新的各种Lua 插件的对比
什么是热更新
? 广义定义
? 无需关闭服务器,不停机状态下修复,更新资源等,重点是更新逻辑代码。
? 狭义定义( iOS热更新)
? 无需将代码重新打包提交至AppStore,即可更新客户端的执行代码,即不用app而自动更新程序。
? 苹果禁止了C#的部分反射操作,禁止JIT(即时编译,程序运行时创建并运行新代码),不允许逻辑热更新,只允许使用AssetBundle进行资源热更新。
为何要热更新
? 缩短用户获取新版应用的客户端的流程,改善用户体验。
? 具体到iOS平台的应用上,有以下几个原因
? App Store的审核周期难控制。
? 手机应用更新频繁。
? 对于大型应用,更新成本太大。
? 终极状态
? 不重新下载、不停机状态下完全变换一个应用的内容。
如何在iOS 上对Unity 应用进行热更新
应用的热更新
? 将执行代码预编译为assemblydll。
? 将代码作为TextAsset打包进Assetbundle。
? 运行时,使用Reflection机制实现代码的功能。
? 更新相应的Assetbundle即可实现热更新。
? Android 与iOS 热更新的 异同
? 苹果官方禁止iOS下的程序热更新;JIT在iOS下无效。
? 热更新方案:Unity+Lua插件。
? 使用Lua 插件进行iOS 热更新的 原理
? Unity 热更新的注意点
? 需要更新的代码、资源,都必须打包成AssetBundle(建议使用未压缩的格式打包)
? 熟悉Unity的几个重要的路径
? Resources(只读)
? StreamingAssets(只读)
? Application.dataPath(只读)
? Application.persistentDataPath(可读写)
? 重要路径之 之Resources
? Resources文件夹下的资源无论使用与否都会被打包
? 资源会被压缩,转化成二进制
? 打包后文件夹下的资源只读
? 无法动态更改,无法做热更新
? 使用Resources.Load加载
? 重要路径之StreamingAssets
? 流数据的缓存目录
? 文件夹下的资源无论使用与否都会被打包
? 资源不会被压缩和
? 打包后文件夹下的资源只读,主要存放二进制文件
? 无法做热更新
? WWW类加载(一般用CreateFromFile ,若资源是AssetBundle,依据其打包方式看是否是压缩的来决定)
? 相对路径,具体路径依赖于实际平台
?Application.streamingAssetsPath
? : Application.dataPath + &/Raw& 或Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/xxx.app/Data/Raw
? 重要路径之Application.dataPath
? 游戏的数据文件夹的路径(例如在Editor中的Assets)
? 很少用到
? 无法做热更新
? IOS路径: Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/xxx.app/Data
? 重要路径之Application.persistentDataPath
? 持久化数据存储目录的路径( 沙盒目录,打包之前不存在 )
? 文件夹下的资源无论使用与否都会被打包
? 运行时有效,可读写
? 无内容限制,从StreamingAsset中读取二进制文件或从AssetBundle读取文件来写入PersistentDataPath中
? 适合热更新
? IOS路径: Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/Documents
? 使用Lua 插件进行iOS 热更新的总体流程
支持Unity iOS 热更新的各种Lua 插件的对比
? uLua(asset store)
? uLua插件原生版本,开山鼻祖
? 不会产生静态代码
? 反射机制,效率低下,速度慢,gcalloc频繁
? 已停止更新维护,不支持Unity5.x,淡出主流
? uLua & cstoLua
? 开发平台成熟稳定,Bug修复迅速
? 开发者众多,资源丰富
? 静态方法,性能优
?有成功商业产品案例(啪啪三国、超神战队、酷鱼吧捕鱼、绝地战警、这不是刀塔等) 鱼、绝地战警、这不是刀塔等)
? 都是基于原生版本的改进;未来,两者会合并成一个插件
? 静态方法,性能优
? 核心代码简洁
? 资源较少,开发平台不够成熟稳定
? 无 无成功商业产品案例 成功商业产品案例
? 基于原生版本的改进
支持Unity iOS 热更新的各种Lua 插件的对比
? C#Light(L#)
? 淡出主流
? 实现的Lua,非完整方案
? 淡出主流
支持Unity iOS 热更新的各种Lua 插件的对比
然后就是 uLua 和 sLua的测试代码。
综合来看 肯定是 uLua 会更好一些。
(window.slotbydup=window.slotbydup || []).push({
id: '2467140',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467141',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467142',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467143',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467148',
container: s,
size: '1000,90',
display: 'inlay-fix'}

我要回帖

更多关于 unity resources 的文章

更多推荐

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

点击添加站长微信