How do I make it to go to a level after an axis has been held down after a certain length of time?

I don’t mind if it’s C# or JS,
I’ve been stuck on this for a while now and need help!
Much appreciated

Here’s the code that I have written myself

using UnityEngine;
using System.Collections;

public class GreenHillsBanner : MonoBehaviour{

private bool m_isAxisInUse = false;
private bool down = false;
private bool up = true;

void Update()
{
if(Input.GetAxis.Down("Triangle")){
			m_isAxisInUse = true;
			down = true;
				up = false;
		}
if(Input.GetAxis.Up("Triangle")){
			m_isAxisInUse = false;
			down = false;
			up = true;
		}
if(down = true){
			yield(WaitForSeconds(3))
			{
				if(down = true){
					Application.LoadLevel("Green Hills");
				}
			if(up = true)
			{
				Application.LoadLevel("SELECTMENU");
			}
	}
}
	}
}

I’d like to know how to improve/make this code work…
thanks and much appreciated

The main problem I see, is that you are using yield. Which means that whenever down = true. it will wait for 3 seconds then activate the code. Regardless if you have released the button earlier.

I would recommend to create a timer instead perhaps.

Such as:

Time timer;
float waitTime = 3f;

if(down=true)
{
      timer = Time.time;
      if((Time.time - timer) > waitTime)
      {
        Application.LoadLevel("Green Hills");
      }
}

Try that instead! =D And you wont have the game bug out with the yield. I have not yet tested the code in the editor, so might be a bit buggy.