why is it that my script only works when i drag it on play into the game object?

it previously worked but i had to drag a material into the inspector to set it. i thought it would be neat to just set it in code rather than dragging and dropping. after some research i found a way, but it now will only spawn the cube when i drag the script into the gameobject on play.

meshbuilder.cs

using UnityEngine;
using System.Collections;
[RequireComponent(typeof(MeshRenderer))]
[RequireComponent(typeof(MeshFilter))]
public class meshbuilder : MonoBehaviour
{   
	//GameObject Cube = new GameObject();
	public Material Red = Resources.Load("Red",typeof(Material)) as Material;
	//front face
	public Vector3 vertice0 = new Vector3(-1,1,1); 
	public Vector3 vertice1 = new Vector3(1,1,1); 
	public Vector3 vertice2 = new Vector3(-1,-1,1); 
	public Vector3 vertice3 = new Vector3(1,-1,1); 
	//back face
	public Vector3 vertice4 = new Vector3(1,1,-1); 
	public Vector3 vertice5 = new Vector3(-1,1,-1); 
	public Vector3 vertice6 = new Vector3(1,-1,-1); 
	public Vector3 vertice7 = new Vector3(-1,-1,-1); 
	//left face
	public Vector3 vertice8 = new Vector3(-1,1,-1);
	public Vector3 vertice9 = new Vector3(-1,1,1);
	public Vector3 vertice10 = new Vector3(-1,-1,-1);
	public Vector3 vertice11 = new Vector3(-1,-1,1);
	//right face
	public Vector3 vertice12 = new Vector3(1,1,1);
	public Vector3 vertice13 = new Vector3(1,1,-1);
	public Vector3 vertice14 = new Vector3(1,-1,1);
	public Vector3 vertice15 = new Vector3(1,-1,-1);
	//top face
	public Vector3 vertice16 = new Vector3(-1,1,-1);
	public Vector3 vertice17 = new Vector3(1,1,-1);
	public Vector3 vertice18 = new Vector3(-1,1,1);
	public Vector3 vertice19 = new Vector3(1,1,1);
	//bottom face
	public Vector3 vertice20 = new Vector3(-1,-1,1);
	public Vector3 vertice21 = new Vector3(1,-1,1);
	public Vector3 vertice22 = new Vector3(-1,-1,-1);
	public Vector3 vertice23 = new Vector3(1,-1,-1);

	// Use this for initialization
	void Start () 
	{
		MeshFilter Filtration = GetComponent<MeshFilter>();
		Mesh CubeMorph = Filtration.mesh;
		GetComponent<MeshRenderer>().material = Red;
	
		//VerticesArray
		Vector3[] VertArray = new Vector3[]
		{
			//Front  Face
			vertice0,//0
			vertice1,//1
			vertice2,//2
			vertice3,//3
			//back face
			vertice4,//4
			vertice5,//5
			vertice6,//6
			vertice7,//7
			//left face
			vertice8,//8
			vertice9,//9
			vertice10,//10
			vertice11,//11
			//right face
			vertice12,//12
			vertice13,//13
			vertice14,//14
			vertice15,//15
			//top face
			vertice16,//16
			vertice17,//17
			vertice18,//18
			vertice19,//19
			//bottom face
			vertice20,//20
			vertice21,//21
			vertice22,//22
			vertice23//23
		};

		//triangles array clockwise points equals visablity
		int[] triArray = new int[]
		{
			//front face
			0,2,3,
			3,1,0,

			//back face
			4,6,7,
			7,5,4,

			//left face
			8,10,11,
			11,9,8,

			//right face
			12,14,15,
			15,13,12,

			//top face
			16,18,19,
			19,17,16 ,

			//bottom face
			20,22,23,
			23,21,20
		};

		//uvs
		Vector2[] uvs = new Vector2[]
		{
			//front face
			new Vector2(0,1),
			new Vector2(0,0),
			new Vector2(1,1),
			new Vector2(1,0),
			//back face
			new Vector2(0,1),
			new Vector2(0,0),
			new Vector2(1,1),
			new Vector2(1,0),
			//left face
			new Vector2(0,1),
			new Vector2(0,0),
			new Vector2(1,1),
			new Vector2(1,0),
			//right face
			new Vector2(0,1),
			new Vector2(0,0),
			new Vector2(1,1),
			new Vector2(1,0),
			//top face
			new Vector2(0,1),
			new Vector2(0,0),
			new Vector2(1,1),
			new Vector2(1,0),
			//bottom face
			new Vector2(0,1),
			new Vector2(0,0),
			new Vector2(1,1),
			new Vector2(1,0)
		};
		CubeMorph.Clear();
		CubeMorph.vertices = VertArray;
		CubeMorph.triangles = triArray;
		CubeMorph.uv = uvs;
		CubeMorph.Optimize();
		CubeMorph.RecalculateNormals();

	}



	
	// Update is called once per frame
	//void Update () {
	//
	//}

}

Do you get an error? The console should be outputting:

ArgumentException: Load can only be called from the main thread.
Constructors and field initializers will be executed from the loading thread when loading a scene
Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.

It’s referring the material:

public Material Red = Resources.Load("Red",typeof(Material)) as Material;

Resources load needs to be in a function. Try moving it to Awake or Start:

public Material Red;
void Awake () {
    if (Red == null) Red = Resources.Load("Red",typeof(Material)) as Material;
}

i removed this

 public Material Red = Resources.Load("Red",typeof(Material)) as Material;

changing this

GetComponent<MeshRenderer>().material = Red;

to this

GetComponent<MeshRenderer>().material = Resources.Load("Red",typeof(Material)) as Material;

and it fixed my problem. Thank you for your reply, I did try it but it did not load the material on the cube. same as my problem was unless i went and dragged it on inspector every play. and at one point the cube was not appearing unless i added it during play. so i created awake function added everything into awake than added awake(); into the start function.