Code Monkey home page Code Monkey logo

unityresourcemgr's Introduction

UnityResourceMgr

项目说明:主要实现基于UNITY资源管理以及更新打包的统一流程机制。有针对资源做Cache并带有一定的资源清理机制。

主要接口:ResourcMgr

切换场景:

  1. ResourceMgr.Instance.CloseScene当前场景
  2. ResourceMgr.Instance.LoadScenex新场景
  3. OnLevelWasLoaded中,调用 AssetCacheManager.Instance.ClearUnUsed(); ResourceMgr.Instance.UnloadUnUsed();

压缩AB, LZ4 AB,非压缩AB,Resources读取都支持。5.3版本支持同步和异步读取所有类型的AB。5.3之前版本,同步函数只支持Resources和非压缩AB, LZ4(5.x才有),异步加载均全支持。 外部使用接口,并不用关心具体文件是在Resources里还是在StreamAssets还是在下载目录,均使用一种方式读取(只有选择同步和非同步的区别)。

--》》重大更新:

1.已经支持LZ4了。另:已经支持同步和异步读取Sprite[]。异步读取LZO压缩,采用5.3版本的LoadFromAsync读取AB。

2.LZMA的读取,在5.3版本采用LoadFromFile和LoadFromFileAsync,在5.3之前版本使用WWW读取(所以5.3可以支持同步和异步,而5.3之前只支持异步)

3.增加了NGUIResLoader, 方便NGUI内部UI框架调用资源加载,简化繁琐的引用计数管理(针对NGUI)

4.增加BaseResLoader, 方便在MonoBehaviour中使用,简化繁琐的引用计数管理

5.依赖文件配置读取,最新采用二进制读取.

6.ResourceMgr的Destroy接口已经支持对原始资源进行Resources.UnloadAsset(第二个参数设置为true),但注意,使用要非常小心,只有非常确认外面没有使用的情况下(Sprite要保证它对应的纹理都没有被其他地方使用),否则其他地方会丢失资源。并且不能针对GameObject进行Resources.UnloadAsset,因为Resources.UnloadAsset只能删除非可见资源。

  7.已经支持DLL热更新,生成DLL热更新步骤:1)右键先编译 CSHARP工程。2)打包APK

  8.增量AssetBundle已经完全支持。

  9.支持脚本一键打包,脚本开发语言为Python, 命令行运行 python autobuild.py或者直接双击autobuild.bat(Windows平台),脚本运行需要安装psUtil库,Windows直接安装psUtil-setup(在AutoBuild/setup里),Mac下查看psutil.sh脚本内容,安装psutil库。

  10.AB的依赖配置文件支持三种方式加载:1.同步加载。2.多线程加载(基于改造后的LOOM库,不使用系统线程池,系统线程池在5.3.8版本会有几率卡死,申请不到额外线程)。3.协程异步加载。     11.增加了增加BaseResLoaderAsyncMono,方便业务逻辑程序使用异步加载的封装简化,以及扩展也容易。

具体说明请看WIKI: https://github.com/billwillman/UnityResourceMgr/wiki/%E7%9B%AE%E5%BD%95

已经支持5.3和5.6版本UNITY, UNITY 2018也做了兼容。Unity 2019打AB以及运行加载是没有问题已测试。

发现Unity 2018更改底层后导致的一个问题:就是AsyncOperation的isDone属性的赋值,貌似UNITY底层放到子线程赋值了,导致主线程同步执行两个函数,isDone的判断不一致,第一个为false, 另外一个为true, 导致有概率资源加载不出来,此问题已经修正。在5.3中,没有此问题。

脚本sign_obb目录里build.py是用来拆分 APK + obb, 用于上GOOGLE平台等海外需求使用。

todo:

1.将读取AssetBundles.xml放在C++层解析,进一步减少MONO堆内存使用量(已经支持二进制,后续可以改为新版本高性能FlatBuffer Table存储)

2.MD5作为文件更改标识,后续可以更改为CRC64或者xxHash的低碰撞的标识减少字符串分配。

unityresourcemgr's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

unityresourcemgr's Issues

ResInstDestroy

GameObject处于visable=false的状态下。不会执行OnDestroy方法

关于依赖

    AssetBundleManifest manifest = BuildPipeline.BuildAssetBundles(exportDir, buildOpts, target);
    EditorUtility.UnloadUnusedAssetsImmediate();

这打包之后manifest是清空了
info.RebuildDependFiles(manifest);
以至于依赖没有获取
这是怎么回事

关于编译csharp功能

编译出来的dll release的应该在
image
这个目录下吧。但是我这边一直没编译出来新的。囧。麻烦有空帮我看看。

读取AssetBundle

你好,读取AssetBundle那里, StreamingAssets文件下的AssetBundles的内容为空, 能不能写点例子呢, 比较好理解一点

Mac 下打包报错

作者您好:
我再Mac平台下,点击平台打包,打OSX的非MD5的包;会报错
1、Switching to : is disabled
2、Building an AssetBundle for target '' is not allowed because the required module is not installed.
请问这个应该怎么解决

ios真机测试资源更新失败几次后就不更新了

请问作者,我在ios真机上测试自动更新的流程,但是它在资源更新失败几次后就直接不更新了,我怀疑是更新失败的时候version.txt更新了但是ab资源包却没有更新,这种情况怎么处理比较好?
不知AutoUpdateClear是否可以解决,我先试试。

bug

你好,工程下载下来之后,报了一个错误,麻烦解决下
tim 20170807172956

关于DLL热更新

请问下DLL热更新是不是只支持安卓平台下的Mono编译而不是IL2CPP? 还是就是DLL热更新不支持iOS平台?

稳定性

这经过项目检验了吗 大佬

[注意事项和项目使用常见问题]中存在的问题

你好!
Wiki中提到的“3.Prefab上不要挂任何脚本,通过代码挂脚本,后面Dll更新会出问题。”

这个“不要挂任何脚本”是怎么理解的?

是指不要在预设体上挂我们用户自定义的脚本吗?(Unity自带的那些不需要更新的呢)

比如我有一个 UI 布局拉成预设体了,是指这个预设体及其下的所有的子GameObject上都不能往预设体上挂脚本吗?
还是只是指这个预设体根节点上不要挂任何脚本??

很疑惑!

关于引用计数的问题

1.记录每个AssetBundle有引用计数,当包含的Asset被加载时,引用计数+1,并且要通过Manifest找到这个Assetbundle依赖的所有Assetbundle,进行引用计数-1
2.记录每个Asset对应的AssetBundle
3.当释放Asset时候,要找到其Assetbundle,引用计数-1,并且要通过Manifest找到这个Assetbundle依赖的所有Assetbundle,进行引用计数-1

这个思路对吗?
另外 ,能加下你QQ吗?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.