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 Introduction

Unity-ImageLoader

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

build in Unity 5.3.4f

用法 Usage

ImageLoader.GetInstance().Display(...);

说明 Instructions

1、可以用于显示的图片类型有:网络图片、本地图片、字节流、Sprite、Texture

Can be used to display the image types are: network image, local image, byte streams, Sprite, Texture

2、带内存及磁盘缓存,默认实现:LRUDiscCache、LRUMemoryCache,也可以自定义实现缓存策略

With memory and disk cache, the default implementation: LRUDiscCache, LRUMemoryCache, can also custom caching strategies

3、默认使用BestHttp请求网络图片,可以自定义实现网络请求

By default use BestHttp to request network images, and you can customize the network request implement

4、图片异步加载使用线程池,默认最大线程数为5

Asynchronous loading images using thread pool,and the default maximum count of threads is 5

License

MIT License

Copyright (c) 2017 Hcq

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

unity-imageloader's People

Contributors

hcq0618 avatar

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

Watchers

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

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.