Добавление паузы

Не работает рестарт, хотя скрипт используется тот же
This commit is contained in:
Vladislav Likhenko 2024-09-09 12:58:35 +03:00
parent 3295cdf462
commit 5f68cbebe4
10 changed files with 73 additions and 7 deletions

40
Assets/EnableMenuSript.cs Normal file
View File

@ -0,0 +1,40 @@
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class EnableMenuSript : MonoBehaviour
{
[SerializeField] private GameObject _Menu;
[SerializeField] private Button[] _Button = new Button[2];
public void EnableMenu()
{
if (_Menu.activeSelf)
{
_Menu.SetActive(false);
Time.timeScale = 1f;
}
else
{
GameObject selectedObject = EventSystem.current.currentSelectedGameObject;
// Ïðîâåðÿåì, åñëè âûáðàííûé îáúåêò ñóùåñòâóåò
if (selectedObject != null)
{
// Åñëè ýòî êíîïêà, ìîæåì ïîëó÷èòü êîìïîíåíò Button
Button selectedButton = selectedObject.GetComponent<Button>();
if (selectedButton != null)
{
selectedButton.GetComponent<Image>().color = Color.white;
}
}
_Menu.SetActive(true);
_Button[0].Select();
Time.timeScale = 0f;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: bf8d5c78394201c448987bead5bf92a9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

11
Assets/PauseScript.cs Normal file
View File

@ -0,0 +1,11 @@
using UnityEngine;
public class PauseScript : MonoBehaviour
{
[SerializeField] private GameObject _Menu;
public void ContinueGame()
{
Time.timeScale = 1f;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d660e4497f0a13a40b55ba050da9a6cb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 0cd8157dcfbd7ea4686914e88dd0c837
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: