Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using UnityEngine.SceneManagement;
- public class Menu : MonoBehaviour
- {
- public GameObject player;
- private void Start()
- {
- }
- public void SaveData()
- {
- Vector3 position = player.transform.position;
- int health = player.GetComponent<PlayerController>().GetHealth();
- PlayerPrefs.SetFloat("playerX", position.x);
- PlayerPrefs.SetFloat("playerY", position.y);
- PlayerPrefs.SetFloat("playerZ", position.z);
- PlayerPrefs.SetInt("health", health);
- PlayerPrefs.Save();
- Debug.Log("SAVED!");
- }
- public void LoadData()
- {
- float x = PlayerPrefs.GetFloat("playerX");
- float y = PlayerPrefs.GetFloat("playerY");
- float z = PlayerPrefs.GetFloat("playerZ");
- int hp = PlayerPrefs.GetInt("health");
- player.transform.position = new Vector3(x, y, z);
- }
- public void StartGame()
- {
- SceneManager.LoadScene(1); //указываем номер сцены для загрузки
- }
- public void Back()
- {
- SceneManager.LoadScene(0);
- }
- public void Credits()
- {
- SceneManager.LoadScene(2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement