Add MainMenuUI component for game start and exit functionality; implement scene loading and browser detection
This commit is contained in:
42
Assets/Scripts/UI/MainMenuUI.cs
Normal file
42
Assets/Scripts/UI/MainMenuUI.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace UI
|
||||
{
|
||||
public class MainMenuUI : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Object mainScene;
|
||||
[SerializeField] private Button exitButton;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
DetectIfBrowser();
|
||||
}
|
||||
|
||||
private void DetectIfBrowser()
|
||||
{
|
||||
if (Application.platform == RuntimePlatform.WebGLPlayer)
|
||||
{
|
||||
exitButton.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void StartGame()
|
||||
{
|
||||
SceneManager.LoadScene(mainScene.name);
|
||||
}
|
||||
|
||||
public void ExitGame()
|
||||
{
|
||||
if (Application.platform == RuntimePlatform.WebGLPlayer)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Application.Quit();
|
||||
}
|
||||
}
|
||||
}
|
3
Assets/Scripts/UI/MainMenuUI.cs.meta
Normal file
3
Assets/Scripts/UI/MainMenuUI.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c900e12a827647ada2f645b798bfb13e
|
||||
timeCreated: 1752406688
|
Reference in New Issue
Block a user