Back button: Implement reactions on Scenes

parent 929d90b5
......@@ -4,6 +4,7 @@ using System.Collections;
using UnityEngine.SceneManagement;
using Assets.Scripts;
using Assets.Scripts.API;
using Assets.Scripts.Utils;
public class GameOver : MonoBehaviour
{
......@@ -28,6 +29,7 @@ public class GameOver : MonoBehaviour
// SceneManager.LoadScene("Menu");
score = PlayerPrefs.GetInt("lastscore");
Score.text = "You scored " + score;
BackButtonHelper.playOnBack();
}
public void OnButtonPlayClicked()
......
using Assets.Scripts.API;
using Assets.Scripts.Utils;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
......@@ -21,6 +22,7 @@ public class HighScores : MonoBehaviour {
// Update is called once per frame
void Update () {
BackButtonHelper.playOnBack();
if (!updatedScores) {
if (Server.Scores.status.Equals("ok")) {
Score[] highScores = Server.Scores.scores;
......
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
using Assets.Scripts.Utils;
public class Menu : MonoBehaviour {
......@@ -11,7 +12,7 @@ public class Menu : MonoBehaviour {
// Update is called once per frame
void Update () {
BackButtonHelper.quitOnBack();
}
public void OnButtonPlayClicked()
......
......@@ -3,6 +3,7 @@ using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using Assets.Scripts;
using Assets.Scripts.Utils;
using UnityEngine.UI;
public class UIController : MonoBehaviour
......@@ -37,6 +38,7 @@ public class UIController : MonoBehaviour
DisplayBattery();
HandlePowerUps();
HandleScore();
BackButtonHelper.menuOnBack();
}
private void HandleScore()
......
using System;
using UnityEngine;
using UnityEngine.SceneManagement;
namespace Assets.Scripts.Utils
{
public static class BackButtonHelper
{
public static void quitOnBack() {
if (Input.GetKeyDown(KeyCode.Escape))
Application.Quit();
}
public static void menuOnBack() {
if (Input.GetKeyDown(KeyCode.Escape))
SceneManager.LoadScene("Menu");
}
public static void playOnBack() {
if (Input.GetKeyDown(KeyCode.Escape))
SceneManager.LoadScene("Main");
}
}
}
fileFormatVersion: 2
guid: 3be153ffde4554d9cbb676f03dc3005d
timeCreated: 1477660884
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment