Add MainMenuUI component for game start and exit functionality; implement scene loading and browser detection

This commit is contained in:
2025-07-13 13:50:32 +02:00
parent 0ca0aeae86
commit 35535fe38a
9 changed files with 2688 additions and 6 deletions

View 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();
}
}
}