Search Unity

Beginner Questions

Discussion in '2D' started by Alex1551, Nov 19, 2018.

  1. Alex1551

    Alex1551

    Joined:
    Nov 17, 2018
    Posts:
    2
    Hello, my name is Alen and I am a beginner with beginner question :S

    What I must do if I want to click anywhere to screen twice with left button but I want to wait to other order.

    Example:


    if (Input.GetMouseButtonDown(0))

    {

    playing = true;

    if (Input.GetMouseButtonDown(0))

    {

    SceneManager.LoadScene("Menu");

    }

    }

    Thank you for all.
     
  2. vakabaka

    vakabaka

    Joined:
    Jul 21, 2014
    Posts:
    1,153
    try this
    Code (CSharp):
    1. bool isClickedOnce = false;
    2.  
    3. void Update ()
    4. {
    5. if (Input.GetMouseButtonDown(0))
    6. {
    7. if (isClickedOnce)
    8. {
    9. SceneManager.LoadScene("Menu");
    10. } else
    11. {
    12. isClickedOnce = true;
    13. }
    14. }
    15. }
     
  3. Alex1551

    Alex1551

    Joined:
    Nov 17, 2018
    Posts:
    2
    Thank you vakabaka :)
    It's exactly what I need.