Search Unity

Feature Request - Stop Button

Discussion in 'General Discussion' started by TheGaul, Dec 27, 2020.

  1. TheGaul

    TheGaul

    Joined:
    Apr 15, 2019
    Posts:
    199
    The most annoying thing about Unity (and surprised this hasn't been fixed in last decade) is this:

    There is no stop button.

    The amount of times I want to stop the game in the editor and I have to de-click the play button but I accidentally clicked it an odd number of times so the game re-starts again!!!!!

    Who agrees? o_O:)

    Who's silly idea was it that you have to click the start button to stop the game! :rolleyes:o_O
     
  2. SparrowGS

    SparrowGS

    Joined:
    Apr 6, 2017
    Posts:
    2,536
    It happens to me a lot too, (especially now that my mouse has a clicking problem, gotta replace it) would be cool if they would add a dedicated button that only stops or make a small delay where it doesn't start when clicked after stopping.
     
  3. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    Happened to me literally about an hour ago lol
     
    Joe-Censored likes this.
  4. spacefrog

    spacefrog

    Joined:
    Jun 14, 2009
    Posts:
    734
    How about getting used to hit the keyboard shortcuts ?
     
  5. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    Or how about Accessibility?
     
    angrypenguin likes this.
  6. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,130
    I think a stop button would be nice, but especially if it contained infinite loop escape functionality like the old Panic Button asset. This would be a nice UX and functionality boon.
     
  7. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,769
    How about unresponsive play and pause/unpause buttons? :)
    But actually, since I haven't checked, can you setup only stop shortcut?

    I am finding all fine with buttons, as long all is nice and responsive. I remember similar thread a year ago or maybe 2. People were complaining about accidental double clicking.

    My issue is however, if testing buggy unresponsive code, with some long loop, lag and trying to stop editor play mode. It is not uncommon in such case, to hit play, or pause few times, hopeing editor will catch one of the hits commands. Then realising, editor pauses and unpauses, or stops and starts after few second lag, which can be annoying. Is like playing a catch game.
     
    SparrowGS likes this.
  8. TheGaul

    TheGaul

    Joined:
    Apr 15, 2019
    Posts:
    199
    There is a keyboard shortcut to stop? :eek: Now you tell me.
     
    Joe-Censored likes this.
  9. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,769
    I meant, I haven't checked, if such exists.
    But since I am now with editor, I could check and there is none.

    upload_2020-12-27_14-12-18.png

    There is also Step shortcut a bit lower in the list (alphabetically ordered).
     
  10. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,609
    Save the following code snippet as
    Editor/PlayModeStopButton.cs

    Code (CSharp):
    1. #if UNITY_EDITOR
    2. using UnityEditor;
    3.  
    4. class PlayModeStopButton
    5. {
    6.     [MenuItem("Edit/Stop", priority = 160)]
    7.     static void DoMenuItem()
    8.     {
    9.         EditorApplication.isPlaying = false;
    10.     }
    11. }
    12. #endif
    ... then go to
    Edit > Shortcuts...
    and pick a shortcut for it.

    upload_2020-12-27_14-34-53.png

    Voila!
     
  11. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,769
    Perfect it works. Thx, I love that magic. :)

    upload_2020-12-27_15-5-34.png

    Wonder if Alt + s vs Ctrl+Shift+Alt + s have pros / cons.
    Or is just up to user preferences?
     
    Peter77 likes this.
  12. Sozno

    Sozno

    Joined:
    Mar 21, 2022
    Posts:
    1
    Fully agree. Absolutely stupid there's not a stop button by default. It's remarkable really. I shake my head everyday.
     
  13. rwarford

    rwarford

    Joined:
    May 28, 2021
    Posts:
    1
    OMG! Am I the only one who pauses the game to inspect something and then hits the PLAY button to start again only to have the game stop??!!!! Every. Single. Time. Grrrrr... At least change the icons on the buttons if you insist on toggles.
     
  14. vertexx

    vertexx

    Joined:
    Mar 18, 2014
    Posts:
    379
  15. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,130
    This thread predates that one by over a year and a half. Who cares?
     
  16. joshuacwilde

    joshuacwilde

    Joined:
    Feb 4, 2018
    Posts:
    726
    Was just about to make a thread for this. Would be a nice QOL feature.
     
  17. Shizola

    Shizola

    Joined:
    Jun 29, 2014
    Posts:
    475
    Yeah I always thought about this, doubt they will add it though. Do they even have a QOL team now Aras is gone?
     
  18. The_Island

    The_Island

    Unity Technologies

    Joined:
    Jun 1, 2021
    Posts:
    502
    For real, I don't even think we need another button. We should not be able to double-click the play button.
     
    Last edited: Sep 5, 2022
    SparrowGS, PaulMDev and DragonCoder like this.
  19. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,130
    We DO need another button. I even mention a specific use case in this very thread:

    The fact that we have to kill the entire editor process if a runaway loop happens in a script is frankly embarrassing.
     
  20. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    7,816
    Whoever codes that loop should wear that shame as they kill the process in Task Manager. :y
     
  21. DragonCoder

    DragonCoder

    Joined:
    Jul 3, 2015
    Posts:
    1,697
    While true, a solution would be handy xP It just happens easier than you'd think after all. Personally I used a selfmade class I use while developing in "risky" loops which exits if there is a ridiculous number of calls.

    However I'd not have expected that a proper solution is apparently possible. There still is an asset that claims to work: https://assetstore.unity.com/packages/tools/utilities/emergency-exit-194959
    Am not quite understanding how it works however. The reason the editor blocks is that it runs on the same thread as your project code (which is necessary as otherwise inspector and scene view would have to deal with race conditions). That asset claims it sends a signal to the main thread, so apparently C# as well as il2cpp automatically react to signals even while looping? That's surprising.
    If it's really easy like that, a feature in Unity would indeed be nice (however since the check has to run in a separate thread it could not be a simple button). The asset uses a keyboard command.
     
  22. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,127
    The .NET CLR (Common Language Runtime) is a virtual machine and the threads that it provides are abstractions on top of the actual threads provided by the OS. Included in the abstraction is code that allows you to request an abort of the thread.

    https://stackoverflow.com/questions/37490841/are-net-threads-different-from-operating-system-threads
    https://stackoverflow.com/questions/1564348/is-the-clr-a-virtual-machine

    IL2CPP is simply translating the IL (Intermediate Language) code into C++ before compiling it but the functionality is not being changed in any way. It's still a virtual machine and your threads are still abstractions. It's just that your code has now been passed through the insane optimization passes of a modern C++ compiler.

    https://blog.unity.com/technology/an-introduction-to-ilcpp-internals

    It's a single script that spawns a second thread that waits for a key combination from the OS. Once that happens it requests an abort of the main thread. Since aborts are handled by .NET by raising an exception the thread watches for that to happen by monitoring the console and once it does it tries to pause the editor.

    https://docs.microsoft.com/en-us/dotnet/api/system.threading.thread.abort
     
    Last edited: Sep 5, 2022
    DragonCoder likes this.
  23. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,130
    Cool, what if it's something from the Asset Store? Or what if the conditions that lead to the loop aren't so easily discoverable in the code due to the complexity that leads to them? I get you're trying to be funny, but this is something that can lead to a lot of needlessly wasted time and should have been solved internally before 2015 when the first asset that allowed this was released.
     
  24. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    7,816
    It was a joke, mate. No need to get so shirty.
     
  25. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,619
    I do like the idea of being able to stop a load deliberately. But you're right, accidentally stopping a play before it starts can be prevented by ignoring clicks during the state change.