Presentation is loading. Please wait.

Presentation is loading. Please wait.

Fundaments of Game Design

Similar presentations


Presentation on theme: "Fundaments of Game Design"— Presentation transcript:

1 Fundaments of Game Design
Unity Scenes and GUI Buttons Richard Gesick

2 Objectives Using multiple scenes in a game
Using GUI buttons and labels

3 Scenes In your scripts, scenes are controlled thru the UnityEngine.SceneManagement library so you need to include it as a using statement. Adding scenes to a Unity game is easy. After saving your current scene, just select file new scene and start its development. To be able to switch scenes during game play, the scenes must be in the scenes in build directory under file build settings

4 Scenes in Build

5 Notes about scenes in build
Each scene has a name and a number and can be called either way. While numbers are easy to sequence, recommend you use names. If a scene is deleted, the remaining numbers adjust for the missing number but it does not get refactored in your code.

6 Control display function
void OnGUI() { if(GUI.Button(new Rect(left,top,width,ht),"Play Game")) SceneManager.LoadScene("mainScene"); } if(GUI.Button(new Rect(left,top+75,width,ht),"Directions")) SceneManager.LoadScene("dirScene");

7 A health bar with a GUI box
public float currentHP = 100; public float maxHP = 100; public float currentBarLength; public float maxBarLength = 100; . . . currentBarLength = currentHP * maxBarLength / maxHP; GUI.Box(new Rect(Screen.width/2 - 20, Screen.height/ , currentBarLength, 25f), "");


Download ppt "Fundaments of Game Design"

Similar presentations


Ads by Google