Skip to content

Commit 062d56e

Browse files
authored
Create README.md
1 parent 1519192 commit 062d56e

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

README.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Unity Async Texture Importer (automatic builds)
2+
3+
This repository is simply a set of build scripts and actions for building and packaging unity-async-textureimport for Unity.
4+
See main repo here: https://codeberg.org/matiaslavik/unity-async-textureimport
5+
6+
This is a faster alternative to [Texture2D.LoadImage](https://docs.unity3d.com/530/Documentation/ScriptReference/Texture2D.LoadImage.html) and , which can only be used on the main thread - and which will block the thread until it's done.
7+
8+
# How to use
9+
Create a [coroutine](https://docs.unity3d.com/Manual/Coroutines.html), and from there do this:
10+
```csharp
11+
TextureImporter importer = new TextureImporter();
12+
yield return importer.ImportTexture(texPath, FREE_IMAGE_FORMAT.FIF_JPEG);
13+
Texture2D tex = importer.texture;
14+
```
15+
See the sample scene for an example.
16+
17+
# What it does
18+
The TextureImporter class has a public IEnumerator ("ImportTexture") that you can call/yield from a coroutine. It runs a task in a separate thread that loads the texture file, converts it to raw data and generates mipmaps. When the task is done, the IEnumerator will finally upload the raw data by calling [Texture2D.LoadRawTextureData](https://docs.unity3d.com/ScriptReference/Texture2D.LoadRawTextureData.html).
19+
Since the file reading, decompressing and mipmap generation is done in a separate thread, you will be able to load large textures without causing FPS lags/hiccups.
20+
I used [FreeImage](https://freeimage.sourceforge.io/) for the texture loading/conversion.
21+
22+
# License
23+
MIT License
24+
(See the "LICENSE" file)
25+
26+
Note: This project uses the FreeImage library. To use this project, you should include a copy of the FreeImage license (GPL or FIPL). See more info here: https://freeimage.sourceforge.io/license.html

0 commit comments

Comments
 (0)