Example #1
0
 /// <summary>
 /// When app loses focus and saveOnLoseFocus is true, save the game.
 /// </summary>
 /// <param name="focusStatus">False indicates game is losing focus.</param>
 void OnApplicationFocus(bool focusStatus)
 {
     if (enabled && saveOnLoseFocus && focusStatus == false && CanSaveInThisScene())
     {
         SaveSystem.SaveToSlot(saveSlotNumber);
     }
 }
Example #2
0
 private void CheckSaveOnQuit()
 {
     if (enabled && saveOnQuit && CanSaveInThisScene())
     {
         SaveSystem.SaveToSlot(saveSlotNumber);
     }
 }
Example #3
0
 /// <summary>
 /// When app is paused (e.g., minimized) and saveOnPause is true, save game.
 /// </summary>
 /// <param name="paused">True indicates game is being paused.</param>
 private void OnApplicationPause(bool paused)
 {
     if (enabled && paused && saveOnPause && CanSaveInThisScene())
     {
         SaveSystem.SaveToSlot(saveSlotNumber);
     }
 }
Example #4
0
 /// <summary>
 /// When app loses focus and saveOnLoseFocus is true, save the game.
 /// </summary>
 /// <param name="focusStatus">False indicates game is losing focus.</param>
 void OnApplicationFocus(bool focusStatus)
 {
     if (saveOnLoseFocus && focusStatus == false)
     {
         SaveSystem.SaveToSlot(saveSlotNumber);
     }
 }
Example #5
0
 /// <summary>
 /// When app is paused (e.g., minimized) and saveOnPause is true, save game.
 /// </summary>
 /// <param name="paused">True indicates game is being paused.</param>
 private void OnApplicationPause(bool paused)
 {
     if (paused && saveOnPause)
     {
         SaveSystem.SaveToSlot(saveSlotNumber);
     }
 }
Example #6
0
 /// <summary>
 /// When quitting, save the game.
 /// </summary>
 private void OnApplicationQuit()
 {
     if (saveOnQuit)
     {
         SaveSystem.SaveToSlot(saveSlotNumber);
     }
 }
Example #7
0
        void OnGUI()
        {
            var originalSkin = GUI.skin;

            if (guiSkin != null)
            {
                GUI.skin = guiSkin;
            }

            // Draw instructions if within the timeframe to do so:
            if (Time.time < m_instructionsDoneTime)
            {
                GUILayout.Label(instructions);
            }

            // Draw menu if visible:
            if (!m_isVisible)
            {
                return;
            }
            var buttonWidth  = buttonSize.x;
            var buttonHeight = buttonSize.y;

            GUILayout.BeginArea(new Rect((Screen.width - buttonWidth) / 2, (Screen.height - 4 * buttonHeight) / 2, buttonWidth, 4 * (buttonHeight + 10)));
            if (GUILayout.Button("Resume", GUILayout.Height(buttonHeight)))
            {
                ToggleMenu();
            }
            if (GUILayout.Button("Save", GUILayout.Height(buttonHeight)))
            {
                ToggleMenu();
                Debug.Log("Saving game to slot " + saveSlot);
                SaveSystem.SaveToSlot(saveSlot);
            }
            if (GUILayout.Button("Load", GUILayout.Height(buttonHeight)))
            {
                ToggleMenu();
                Debug.Log("Loading game from slot " + saveSlot);
                SaveSystem.LoadFromSlot(saveSlot);
            }
            if (GUILayout.Button("Quit", GUILayout.Height(buttonHeight)))
            {
                ToggleMenu();
                Debug.Log("Quitting");
                Application.Quit();
#if UNITY_EDITOR
                UnityEditor.EditorApplication.isPlaying = false;
#endif
            }
            GUILayout.EndArea();
            if (guiSkin != null)
            {
                GUI.skin = originalSkin;
            }
        }
Example #8
0
        void OnGUI()
        {
            // Draw instructions if within the timeframe to do so:
            if (Time.time < instructionsDoneTime)
            {
                GUILayout.Label(instructions);
            }

            // Draw menu if visible:
            if (!m_isVisible)
            {
                return;
            }
            const int ButtonWidth  = 200;
            const int ButtonHeight = 30;

            GUILayout.BeginArea(new Rect((Screen.width - ButtonWidth) / 2, (Screen.height - 4 * ButtonHeight) / 2, ButtonWidth, 4 * (ButtonHeight + 10)));
            if (GUILayout.Button("Resume", GUILayout.Height(ButtonHeight)))
            {
                ToggleMenu();
            }
            if (GUILayout.Button("Save", GUILayout.Height(ButtonHeight)))
            {
                ToggleMenu();
                Debug.Log("Saving game to slot " + saveSlot);
                SaveSystem.SaveToSlot(saveSlot);
            }
            if (GUILayout.Button("Load", GUILayout.Height(ButtonHeight)))
            {
                ToggleMenu();
                Debug.Log("Loading game from slot " + saveSlot);
                SaveSystem.LoadFromSlot(saveSlot);
            }
            if (GUILayout.Button("Quit", GUILayout.Height(ButtonHeight)))
            {
                ToggleMenu();
                Debug.Log("Quitting");
                Application.Quit();
#if UNITY_EDITOR
                UnityEditor.EditorApplication.isPlaying = false;
#endif
            }
            GUILayout.EndArea();
        }
 /// <summary>
 /// Saves the current game in the specified slot.
 /// </summary>
 /// <param name="slotNumber"></param>
 public void SaveSlot(int slotNumber)
 {
     SaveSystem.SaveToSlot(slotNumber);
 }