public static byte[] WriteToByteArray(this AssetTypeInstance instance) { byte[] data; using (MemoryStream ms = new MemoryStream()) using (AssetsFileWriter w = new AssetsFileWriter(ms)) { instance.Write(w); data = ms.ToArray(); } return(data); }