Interactive Media

Mohamed Al-Kaf - Media Explorations

Start Screen & Level Two

Written by: Mohamed Al-Kaf | Posted on: | Category:

Creating a menu screen using UI elements texts and buttons. when adding Buttons an event system is added.

Screenshot 2019-05-01 at 11.09.17 pm.png

I also added a script to an empty game object called the main menu.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class MainMenu : MonoBehaviour
{
public void PlayGame()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
}
public void QuitGame()
{
Debug.Log("Quit");
Application.Quit();
}
}

This create two public functions. So any time that are called the code will run. For example in the button inspector settings click option to the Script and function and this makes the button call that code.

Screenshot 2019-05-01 at 11.21.14 pm.png