var path = EditorUtility.SaveFilePanelInProject("Save texture as PNG", texture.name + ".png", "png", "Please enter a file name to save the texture to"); if(path.Length != 0) { // Convert the texture to a format compatible with EncodeToPNG if(texture.format != TextureFormat.ARGB32 && texture.format != TextureFormat.RGB24) { var newTexture = Texture2D(texture.width, texture.height); newTexture.SetPixels(texture.GetPixels(0),0); texture = newTexture; } var pngData = texture.EncodeToPNG(); if(pngData != null) { File.WriteAllBytes(path, pngData); // As we are saving to the asset folder, tell Unity to scan for modified or new assets AssetDatabase.Refresh(); } } }