Sphere with texture using C# scripting

I’m newbie in unity.

I’ve started 2D project and tried to create globe object through scripting and got fail.
The problem the texture doesn’t apply my dynamically rendered sphere object.

using UnityEngine;
using System.Collections;

public class Hyper : MonoBehaviour {

	// Use this for initialization
	void Start () {
		Debug.Log("2D Globe Projection");
		GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
		sphere.transform.position = new Vector3(0, 0, 0);
		Texture tex = Resources.Load("earth", typeof(Texture)) as Texture;
		sphere.GetComponent<Renderer>().material.SetTexture("_MainTex", tex);
	}
	
	// Update is called once per frame
	void Update () {
	
	}
}

This script is attached to camera object.

Please help to solve that problem.

Note: The texture ‘earth’ is located in Assets/Resources folder.

Thank you!

Texture runtimeTexture = (Texture) Resources.Load(“earth”);
Material runtimeMaterial = new Material(Shader.Find(“VertexLit”));
runtimeMaterial.SetTexture(“_MainTex”, runtimeTexture);

		sphere.GetComponent<Renderer>().material = runtimeMaterial;

Solved by me.