I build a quad from code and assign a texture to it, it works when i start the game from the editor. When i build the game and launch the .exe the quad is white without textures.
This is the code
public GameObject create_ground_object(float w,float h)
{
Mesh mesh = create_ground_quad(w,h);
GameObject ground = new GameObject("ground",typeof(MeshRenderer),typeof(MeshFilter));
ground.GetComponent<MeshFilter>(). sharedMesh = mesh;
Texture texture = (Texture) Resources.Load(terrain_type);
ground.GetComponent<Renderer>().material.mainTexture = texture;
var shader = Shader.Find ("Unlit/Transparent");
ground.GetComponent<Renderer>().material.shader = shader;
return ground;
}
If i add at the end of the function:
Debug.Log ("texture name "+texture.name);
Debug.Log ("texture height "+texture.height);
Debug.Log ("shader name "+shader.name);
they are all correct.
The textures are in the resource folder and i added the shader to the include list.
Why my quad is white?