Advertisement
LeeMace

UI Start Game and Quit Application

Jan 9th, 2023 (edited)
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.53 KB | Gaming | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. #if UNITY_EDITOR
  5. using UnityEngine;
  6. #endif
  7. using UnityEngine.SceneManagement;
  8.  
  9. //remember to assign the button and drag canvas into the On Click and assign the function
  10.  
  11. public class MenuUIHandler : MonoBehaviour
  12. {
  13.     public void StartNew()
  14.     {
  15.         SceneManager.LoadScene(1);
  16.     }
  17.  
  18.     public void Exit()
  19.     {
  20. #if UNITY_EDITOR
  21.         UnityEditor.EditorApplication.ExitPlaymode();
  22.  
  23.         #else
  24.         Application.Quit();
  25. #endif
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement