/
arti4
/
Diplom
Обзор
Документация
Войти
/
arti4
/
Diplom
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Scripts/Scenes/GameManager.cs
60 строк
1 KB
arti4
Загрузка всех скриптов
17 май 2026, 09:08
Верифицирован
17 май 2026, 09:08
cc2e1cd
Код
Авторство
О чём код?
using UnityEngine; using UnityEngine.SceneManagement; public class GameManager : MonoBehaviour { [Header("References")] [SerializeField] private GameProgress gameProgress; [SerializeField] private GameObject player; [SerializeField] private GameObject loadingCanvas; void Start() { if (gameProgress == null) { gameProgress = FindObjectOfType<GameProgress>(); } LoadSavedGame(); } void LoadSavedGame() { if (gameProgress == null) { Debug.LogWarning("GameProgress �� ������!"); return; } GameData data = gameProgress.LoadGame(); if (data != null) { if (player != null) { player.transform.position = data.playerPosition; } } } public void SaveGame() { if (gameProgress == null) return; GameData data = new GameData(); if (player != null) { data.playerPosition = player.transform.position; } data.level = SceneManager.GetActiveScene().buildIndex; gameProgress.SaveGame(data); } public void NewGame() { gameProgress.DeleteSave(); SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex); } }