How to make a gameobject take you to a scene when clicked?

I am making a game and made a main menu and some scenes. I’m trying to implement it so when you click on the gameobject (In my case a rectangle) it will take you to the level that you define. Any help? Thanks

make an if then statement that when mousebutton is released it does Application.LoadLevel (1) or whatever. you add scenes under file > build settings and it tells you which number it is, then type that number in. here is an example of how I made public variables and dropped each menu item into them inside the inspector to use them.

  1. var isExit=false;
    var isPlay=false;
    var isCredit=false;
    public var Creator : GameObject;
    public var Asset : GameObject;
    public var Will : GameObject;
    public var Unity : GameObject;

    function OnMouseEnter()
    {
    	renderer.material.color=Color.gray;
    }
    function OnMouseExit()
    {
    	renderer.material.color=Color.white;
    }
    function OnMouseUp(){
    	if (isExit==true) 
    	{
    		audio.Play();
    		Creator.active=false;
    		Asset.active=false;
    		Will.active=false;
    		Unity.active=false;
    		yield WaitForSeconds (1);
    		Application.Quit();
    		}
    	if (isPlay==true) 
    	{
    		audio.Play();
    		Creator.active=false;
    		Asset.active=false;
    		Will.active=false;
    		Unity.active=false;
    		yield WaitForSeconds (1);
    		Application.LoadLevel(1);
    		}
    	if (isCredit==true) 
    	{
    		audio.Play();
    		Creator.active=true;
    		Asset.active=true;
    		Will.active=true;
    		Unity.active=true;
    	}
    }
    

this also has code for making the text turn grey when hovered over, playing a clicking sound when clicked, and activating more text if the credits text is selected. hope this helped at all.

Make sure to make isTriangle true when you start the scene and attach the object to the triangle.

using UnityEngine;
using System.Collections;

public class LoadLevel : Monobehavior 
{
      public bool isTriangle;
      void OnMouseDown()
       {
         if(isTriangle = true)
         {
           Application.LoadLevel("LevelName");
         }
       }
}

C#:

 void OnMouseDown() {
      Application.LoadLevel ("SceneName");
    }