using UnityEngine;
using System.Collections;

public class LevelButtonBehavior : MonoBehaviour 
{
	public string loadLevelName;

	private Ray ray;
	private RaycastHit hit;


	void Update () 
	{
		if(Input.GetMouseButtonDown(0))
		{
			CheckLevelButton(Input.mousePosition);
		}
	}


	void CheckLevelButton(Vector3 position)
	{
		ray = Camera.main.ScreenPointToRay(position);
		Physics.Raycast(ray, out hit, 5000.0f);

		if(hit.collider == this.collider)
		{
			Application.LoadLevel (loadLevelName);
		}
	}
}
