- Home /
Implementing Level ID
Hello, everyone
I am working on a script for a school assignment where I have to implement a level ID or reference for use in case later levels are implemented to easily transition between them. Does anyone have any idea how to do this? I placed the exact instructions and the core game script down below. Plz let me know how I can go about doing this.
using UnityEngine; using System.Collections;
public class CoreGame : MonoBehaviour {
// Reference to the pause menu
[SerializeField] GameObject pauseMenu;
// Variable of the handle paused function that checks if it were true.
private bool paused = false;
// This is for initialization
void Start () {
// Start a screen fade up
ScreenFader.CreateFade("ScreenFadeUp", FadeUpCompleted);
// Hide the pause menu initially
HandlePause (false);
}
// Helper to attach a game object as a child to the core game
static public void MakeChild (GameObject _child) {
// Find the "instance" of the core game object.
GameObject coreGameObj = GameObject.Find("CoreGame");
// Assign the child's transform's parent to the
// recently found core game's transform.
_child.transform.parent = coreGameObj.transform;
}
// Invoked when the fade has completed.
void FadeUpCompleted () {
Debug.Log ("Fade UP has completed!");
}
// Update is called once per frame
void Update () {
CheckInput();
}
// Polls user input
void CheckInput () {
// User has pressed pause?
if (Input.GetKeyUp (KeyCode.P)) {
HandlePause(!paused);
}
}
// Handles the actions of the pause event
public void HandlePause(bool _pause) {
// Assign new pause status
paused = _pause;
// Send a message to all children
BroadcastMessage ("SetPaused", paused);
// Halt or start the progression of time
if (paused)
Time.timeScale = 0;
else
Time.timeScale = 1;
// Change the menu's visibility
pauseMenu.SetActive (paused);
}
}
core game level id.png
(30.3 kB)
Comment
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
How to start in Unity? 1 Answer
How much money can I make for a good game in Unity Union? 1 Answer
creating a game? 3 Answers
MOBA game creation resources 1 Answer