Coder Social home page Coder Social logo

hcq0618 / unity-imageloader Goto Github PK

View Code? Open in Web Editor NEW
73.0 12.0 20.0 1.12 MB

用于Unity中的图片异步显示加载库 async load and display image in unity

License: MIT License

C# 100.00%
unity imageloader sprite texture image ugui besthttp memory-cache disc-cache threadpool

unity-imageloader's Issues

Main Thread

My Unity app loads lots of large images from a server, this causes Unity to freeze while decoding and rendering the image becuase this is all done on the main thread.

Does your code still use the main thread to load the images onto textures?

To test have a code like this

void Update()
{
transform.rotate(Vector3(1,0,0)* Time.deltatime*10);
}

Run that while loading several images using your code, see if the object being rotated ever pauses and then resume rotation.

图片多时会卡,最大的瓶颈就在那一行

Texture2D texture = new Texture2D(width, height, TextureFormat.ARGB32, false);
texture.LoadImage(data);

纹理创建和纹理数据载入不能在子线程中做,只能在主线程。一旦下载的图片是png、jpg等格式,LoadImage内部会解码元数据格式到ARGB32,这个是比较花费CPU的,所以图片多一些的时候,卡顿会很明显。好一点的做法考虑在收到http下载的图片数据后。自己写一个解码图片的函数在线程中计算解码。然后在主线程中把解码后的数据直接通过SetPixels或LoadRawTextureData。这样会减少卡顿。

Example please

Hello, I found your project is very promising.
Can you please provide any working sample?

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.