Unity - Can't get AssetPreview to work

Hello everyone, I have a problem using AssetPreview.GetAssetPreview, I’ll try to be as much specific as possible.

This is what I want to do:

this is my script:

if (IsSelectingCar){

if (GUI.Button(Rect(Screen.width/2.1,Screen.height/4,100,100),AssetPreview.GetAssetPreview(CarList[0]))){

}

if (GUI.Button(Rect(Screen.width/4,Screen.height/4,100,100),AssetPreview.GetAssetPreview(CarList[1]))){

	}

if (GUI.Button(Rect(Screen.width/1.414213562373095,Screen.height/4,100,100),AssetPreview.GetAssetPreview(CarList[2]))){

}

if (GUI.Button(Rect(Screen.width/2.1,Screen.height/2,100,100),AssetPreview.GetAssetPreview(CarList[3]))){

}

if (GUI.Button(Rect(Screen.width/4,Screen.height/2,100,100),AssetPreview.GetAssetPreview(CarList[4]))){

	}

if (GUI.Button(Rect(Screen.width/1.414213562373095,Screen.height/2,100,100),AssetPreview.GetAssetPreview(CarList[5]))){

}

(It’s just part of the script of course)

now, everything works fine inside the editor, but when I try to build, here’s what happens:

I didn’t manage to find any solution for this, and no, I don’t want to buy anything from anyone, I prefer to do things by myself instead of buying 'em from people

Hi,
AssetPreview is an editor class. So it only works in the editor!
Read about editor scripting it is used to extend the unity editor.
You can only render the images in the editor and then use them in play mode!

does anyone know a workaround for this then?

Like I said before.

Example:

var bytes=texture.EncodeToPNG();
var file = new File.Open(Application.dataPath + "/"+fileName,FileMode.Create);
var binary= new BinaryWriter(file);
binary.Write(bytes);
file.Close();