1. Before you ask anything, make sure that you've read the FAQ

Game Suggestion Game Escape

Discussion in 'Suggestions' started by Snow, Dec 1, 2015.

Thread Status:
Not open for further replies.
  1. Snow

    Snow Member

    • Donor
    Joined:
    Dec 1, 2015
    Messages:
    16
    Likes Received:
    5
    I thought this would be a good add-on. A way to quit the game. I wrote this script for my game and I am giving it to you for your :D
    Code:
    using UnityEngine;
    using System.Collections;
    
    public class exit : MonoBehaviour {
    
        void Start () {
       
        }
    
        void Update () {
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                Debug.Log("Attempting quit...");
                if (Application.isEditor == false) {
                    Debug.Log("Quitting...");
                    Application.Quit();
                } else if (Application.isEditor == true) {
                    Debug.Log("Quit denied REASON: IsInEditor == true");
                }
            }
            if (Application.isEditor == false) {
                if (Application.genuine == false) {
                    Application.Quit();
                }
            }
        }
    }
     
  2. B1G-CR1ME

    B1G-CR1ME Guest

    Syrs doesn't really need help with the coding.

    Besides, since when the 'close' button is not suitable for that?
     
  3. Snow

    Snow Member

    • Donor
    Joined:
    Dec 1, 2015
    Messages:
    16
    Likes Received:
    5
    Simple, when there isn't a close button. Unless I'm missing something?
     
  4. B1G-CR1ME

    B1G-CR1ME Guest

    I guess you are... although I can't believe that the big red X at the top right of your window isn't there. Say, are you not using Windows?
     
  5. Snow

    Snow Member

    • Donor
    Joined:
    Dec 1, 2015
    Messages:
    16
    Likes Received:
    5
    That "Big red X" is only there if you are NOT in full screen. It is much better to be in full screen.
     
    Magiichan likes this.
  6. Magiichan

    Magiichan Administrator

    • Admin
    • Coder
    Joined:
    May 25, 2015
    Messages:
    249
    Likes Received:
    157
  7. B1G-CR1ME

    B1G-CR1ME Guest

    No, it is not. With fullscreen on, you can't snap to other windows without Alt-Tabbing, AND you get less FPS unless you're using a screen most tiny/have a machine most powerful.

    Then again, you probably don't just go around exiting Zerahypt very often. Do ya, punk?
     
  8. Magiichan

    Magiichan Administrator

    • Admin
    • Coder
    Joined:
    May 25, 2015
    Messages:
    249
    Likes Received:
    157
    Actually, fullscreen provides an evironment where the FPS will be higher.
    In windowed, the drawed frames have to be casted to a windows forms application, which will take up more resources & cap your framerate.
    While in fullscreen, the selected resolution will be scaled to your monitor's resolution. So the screen size doesn't really play a big role.
    The more you know ^u^
     
  9. Demimoz Keroz

    Demimoz Keroz Well-Known Member

    Joined:
    Nov 3, 2015
    Messages:
    91
    Likes Received:
    19
    Actually, a whole pause menu would be nice. Just saying. I don't have time to mod it myself, because hell is a busy place.
     
  10. BluetoothBoy

    BluetoothBoy Well-Known Member

    • Coder
    Joined:
    Jun 3, 2015
    Messages:
    77
    Likes Received:
    50
    Generally not a good idea to quit a game with a single key-press. This would be far better suited for a pause menu.
     
  11. B1G-CR1ME

    B1G-CR1ME Guest

    I got FPS drops in the fullscreen either way.
     
  12. BluetoothBoy

    BluetoothBoy Well-Known Member

    • Coder
    Joined:
    Jun 3, 2015
    Messages:
    77
    Likes Received:
    50
    All that means is that your hardware is not up to par to the game's requirements for whatever resolution/quality you were playing at (or you had too many other things open).

    If you use my console mod, you can view your in-game framerate. Just an FYI, the game is automatically capped at 60 FPS anyway.
     
  13. B1G-CR1ME

    B1G-CR1ME Guest

    I suppose it's poorly optimised, then - I had many games running much smoother with a [way] higher overall LOD using the same res... taking into account that I usually don't get more than forty per second in Zerahypt on low-Q, that is.
    Not that I'm complaining, though.
     
  14. BluetoothBoy

    BluetoothBoy Well-Known Member

    • Coder
    Joined:
    Jun 3, 2015
    Messages:
    77
    Likes Received:
    50
    True, the game is somewhat poorly optimized - that is a definite factor. Even so, I get an even 60 FPS constantly, so it's not too terrible...
     
  15. Snow

    Snow Member

    • Donor
    Joined:
    Dec 1, 2015
    Messages:
    16
    Likes Received:
    5
    Here is an update to the EXIT script I have been working on. Maybe in the next version I will make it have a menu or something but I don't know right now.
    Code:
    using UnityEngine;
    #if UNITY_EDITOR
    using UnityEditor;
    #endif
    
    public class exit : MonoBehaviour
    {
    
        // Use this for initialization
        void Start()
        {
    
        }
    
        // Update is called once per frame
        void Update()
        {
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                Debug.Log("Attempting quit...");
                if (Application.isEditor == false)
                {
                    Debug.Log("Quitting...");
                    Application.Quit();
                    //System.Diagnostics.Process.GetCurrentProcess().Kill();  // <--This works if the other crashes the client.
                }
                else if (Application.isEditor == true)
                {
    #if UNITY_EDITOR
                    if (EditorApplication.isPlaying == true)
                    {
                        EditorApplication.isPlaying = false;
                        Debug.Log("Quit denied REASON: IsInEditor == true");
                        Debug.Log("PlayMode has been dissabled.");
                    }
    #endif
                }
            }
            if (Application.isEditor == false)
            {
                if (Application.genuine == false)
                {
                    Application.Quit();
                }
            }
        }
    }
    
    
     
  16. BluetoothBoy

    BluetoothBoy Well-Known Member

    • Coder
    Joined:
    Jun 3, 2015
    Messages:
    77
    Likes Received:
    50
    W
    Why have the editor code? It's not really useful, seeing as this code would only ever be used in a mod, which is never going to be used in the editor.
     
  17. Snow

    Snow Member

    • Donor
    Joined:
    Dec 1, 2015
    Messages:
    16
    Likes Received:
    5
    Because this code will never be used in a mod. I use this code all the time in the editor. It makes it quick and easy to stop the Play button, and in a build it makes it easy to quit the game without crashing or ALT + TAB to just quit the game like Zerahypt. I personally love Zerahypt, but quitting the game in full screen can be such a pain, and no I am NOT going to be making a mod. I am not a modder, but if you want to use my script in a mod, than by all means you have my permission to use it to do so, you also have my permission to use my script in your own game without my written permission as well. My game locks the mouse down to the center of the screen and makes it invisible too, even in the editor at run time.
     
  18. Azai

    Azai Moderator

    • Mod
    Joined:
    May 25, 2015
    Messages:
    109
    Likes Received:
    91
    Personally, I'd say an exit upon hitting Esc would be too instantaneous. I'd suggest displaying a confirmation window, but at that point, the action of quitting the game requires pressing a button and then clicking a button. So that solution would start looking similar to just Alt+Tabbing out, and closing the application.
    Regardless, it's still simpler even with the confirmation window, so I would suggest adding this feature, given that a confirmation window is displayed.
     
    BluetoothBoy likes this.
  19. BluetoothBoy

    BluetoothBoy Well-Known Member

    • Coder
    Joined:
    Jun 3, 2015
    Messages:
    77
    Likes Received:
    50
    I guess my point was you usually don't put extraneous code in an actual game build is all. Unfortunately, the game is unoptimized enough as it is, so extra code simply makes this worse. Of course, this is a very minuscule amount of editor code and would barely cause a hiccup, but it's more the concept that counts in this case. If it was your intention for that to be used in the editor as-is, and removed for the build, that makes more sense to me. I totally understand why it would be used in the editor, though. ;)
     
Thread Status:
Not open for further replies.