Making a 2D Game in unity part-6

Now we are going to make a manager for the game. Create an empty gameobject and name it manager. Make a new c# script and name it manager. attach the script to the manager game object. Open it on mono behaviour. copy paste this script and save it.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class manager : MonoBehaviour {

public GameObject pauseButton;
public GameObject PausePanel;
public Text score;
public GameObject player;

public static bool gameOver;
public static int myScore;
// Use this for initialization
void Start () {
    gameOver = false;

// Update is called once per frame
void Update () {


public void pause()
    Time.timeScale = 0f;
    PausePanel.SetActive (true);

public void mainMenu()
    SceneManager.LoadScene ("menu");

public void resume()
    Time.timeScale = 1f;
    PausePanel.SetActive (false);

public void restart()

public void quite()
    Application.Quit ();

public void checkHighScore()
        int highScore = PlayerPrefs.GetInt ("High Score");
            PlayerPrefs.SetInt ("High Score",highScore);


after saving it we will see a bunch of variables from the inspector.


this manager script handels the ui management and score counting. When we press the pause button the the game willbe paused and a the pause panel will appear. pause panel will have some button with it like -main menu -resume -restart -quit

manager will also handel them. we will make a pause button,pause panel a text ui for score. for now just drag and drop the player from the hierachy into the player variable slot of manager



Boostlog is an online community for developers
who want to share ideas and grow each other.

Delete an article

Deleted articles are gone forever. Are you sure?