import System.Collections;
import System.IO;
@MenuItem("Assets/Export Texture")
static function Apply () {
var texture : Texture2D = Selection.activeObject as Texture2D;
if (texture == null)
{
EditorUtility.DisplayDialog("Select Texture", "You Must Select a Texture first!", "Ok");
return;
}
var bytes = texture.EncodeToPNG();
File.WriteAllBytes(Application.dataPath + "/exported_texture.png", bytes);
}
^ I use to export the splatmap of my Terrain in unity3d this script (over here)^
But it fails everytime, because i cant see anything on the .png. Its only an empty picture, but if i look in unity3d then there is the png with a picture.
I hope somebody knows whats wrong ._.
Pictures below here:
The “empty” .png :
2 picture