Search Unity

Escape Key to Close Application?

Discussion in 'Visual Scripting' started by StardustBlaze, Jan 11, 2022.

  1. StardustBlaze

    StardustBlaze

    Joined:
    Feb 25, 2018
    Posts:
    16
    EscapeKeyProblem.PNG

    Hey everyone, I'm kinda new to Unity. I mean, I've used it in the past for a high school class, but that's about it. Anyway, as you can see in the image I've attached, I'm trying to make a command where players can press the Escape key to exit and close the game entirely. However, it's not working using the Visual Scripting code I've written. So what did I do wrong? Is there something in Visual Scripting I should be doing to make the game exit and close when players press the Escape key? I look forward to hearing back from you soon.
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,909
    Two issues here:
    1. Unity has special bindings on the escape key in the editor, so it often doesn't work when you bind a key to Escape and try to use it in the editor
    2. Application Quit doesn't work in the editor either (or else it would quit the editor itself). The typical workaround from a C# script goes like this http://answers.unity.com/answers/1157271/view.html I'm not sure how you'd do it in Bolt/Visual Scripting.
     
  3. StardustBlaze

    StardustBlaze

    Joined:
    Feb 25, 2018
    Posts:
    16
    Thanks for the tip. What script should I put this C# code into?
     
  4. Vryken

    Vryken

    Joined:
    Jan 23, 2018
    Posts:
    2,106
    Any custom script will do.
     
  5. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,474
    So you know, there's a dedicated Visual Scripting sub-forum you can use. I'll move your post there.