imLor
1
Hey! Things to add to the code. I want to load the scene after 5 seconds of holding!
Can you tell me Please?
public string [] SceneNames;
void OnMouseDown ()
{
int s = Random.Range (0, SceneNames.Length) ;
SceneManager.LoadScene(SceneNames~~);~~
}
private float mouseDownTime;
void Update()
{
bool hasBeenClicked = mouseDownTime > 0;
if(hasBeenClicked)
{
bool timeHasElapsed = Time.time > mouseDownTime + 5;
if(timeHasElapsed)
{
int s = Random.Range (0, SceneNames.Length) ;
SceneManager.LoadScene(SceneNames~~);~~
}
if(Input.GetMouseButtonUp(0))
{
mouseDownTime = -1f;
}
}
}
void OnMouseDown ()
{
mouseDownTime = Time.time;
}