I wrote a simple script. I need to know three things!
- How to attach a script to a GUI Button?
- How to make a button call a specific function within the script?
- What command to use to quit the application and return to Windows (or MacOS if you’re using a Macintosh)?Here is the script I wrote!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class NewBehaviourScript : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
// Button 1 click, the start button
void StartGame() {
SceneManager.LoadScene(“Scene One”);
}
// Button 2 click, the quit button
void QuitGame() {
SceneManager.UnloadScene(“Scene Title”);
}
}