byte[] Raw texture data as a byte array.
Get raw data from a texture.
This function returns the raw texture data as a byte array, which you can then use with Texture2D.LoadRawTextureData. This allows you to serialize and load textures of any format (including compressed ones), and to load them back into a texture later.
using UnityEngine;
class CopyTexture: MonoBehaviour { // the source texture. Texture2D tex;
void Start() { // Create a copy of the texture by reading and applying the raw texture data. Texture2D texCopy = new Texture2D(tex.width, tex.height, tex.format, tex.mipmapCount > 1); texCopy.LoadRawTextureData(tex.GetRawTextureData()); texCopy.Apply (); } }