How to get the pixels of a texture which is in memory

I make some texture into AssetBundle, and loaded it in memory.
I want to patch all texture in assetBundle into one atlas.
But can’t get the pixels of each texture.

code like this:


got error:

Texture 001 is not readable, the texture memory can not be accessed from scripts.
You can make the texture readable in the Texture Import Settings.

whether the Unity locked the memory block where the assetBundle used or not.
and what should i do.

Thanks in advance!

There is another way to bypass the read/write restriction;

basically its the operation you perform when rescaling a texture (but in this case you don’t actually rescale - see

Perhaps the following code can be optimized, but it works:

Color32[] pixelBlock = null;
                pixelBlock = img.GetPixels32();
            catch (UnityException _e)
                img.filterMode = FilterMode.Point;
                RenderTexture rt = RenderTexture.GetTemporary(img.width, img.height);
                rt.filterMode = FilterMode.Point;
       = rt;
                Graphics.Blit(img, rt);
                Texture2D img2 = new Texture2D(img.width, img.height);
                img2.ReadPixels(new Rect(0, 0, img.width, img.height), 0, 0);
       = null;
                img = img2;
                pixelBlock = img.GetPixels32();

you need to set the texture as readable before GetPixels or SetPixels;
see the unity script reference ( i use one simple google search )

Thanks very much erick_weil.
Finally, i achieve it via file operation.
Here is another answer: