Git Product home page Git Product logo

unitydownloadplus's Introduction

引言

通常我们在Unity中下载一个网络上的资源到本地时,简单的方式是使用WWW类进行下载,然后将Byte[]写到本地。但是这种方式有个隐藏问题就是,网络上的资源会被预先全部加载到内存中,才能被写到本地。于是我查了下资料,然后用WebClient类简单封装了一个使用方法类似WWW的下载类。在下载资源时可以有效地避免内存的增长,尤其是下载很大的资源包时特别有用。

方案优势

  • 在下载资源时可以有效地避免内存的增长,尤其是下载Size很大(上百兆)的资源包时特别有用。

文章DEMO对应的IDE版本

  • Unity 5.6.5 测试通过,理论上都兼容

总结

  • 建议将网络加载的资源分为两类,不需要存到本地的资源直接用WWW加载到内存中使用,需要存到本地的资源使用封装的Downloader类进行下载。
  • 如果有特殊需要,可以修改Downloader类实现断点续传功能。

DEMO地址

unitydownloadplus's People

Contributors

jinglikeblue avatar

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.