kadyr

Untitled

Sep 15th, 2021
671
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using UnityEngine;
  2. using UnityEngine.SceneManagement;
  3.  
  4. public class Menu : MonoBehaviour
  5. {
  6.     public void StartGame()
  7.     {
  8.         SceneManager.LoadScene(0); //указываем номер сцены для загрузки
  9.     }
  10.  
  11.     public void Back()
  12.     {
  13.         SceneManager.LoadScene(0);
  14.     }
  15.  
  16.     public void Credits()
  17.     {
  18.         SceneManager.LoadScene(2);
  19.     }
  20.  
  21.     [SerializeField] GameObject player;
  22.  
  23.  
  24.     public void Save()
  25.     {
  26.         Vector3 vector = player.transform.position;
  27.         int health = player.GetComponent<PlayerController>().GetHealth();
  28.         PlayerPrefs.SetFloat("playerX", vector.x);
  29.         PlayerPrefs.SetFloat("playerY", vector.y);
  30.         PlayerPrefs.SetFloat("playerZ", vector.z);
  31.         PlayerPrefs.SetInt("health", health);
  32.         PlayerPrefs.Save();
  33.     }
  34.  
  35.     public void Reset()
  36.     {
  37.         PlayerPrefs.SetFloat("playerX", 596.9f);
  38.         PlayerPrefs.SetFloat("playerY", 0.4f);
  39.         PlayerPrefs.SetFloat("playerZ", 733.7f);
  40.         PlayerPrefs.SetInt("health", 100);
  41.         PlayerPrefs.Save();
  42.     }
  43. }
  44.  
RAW Paste Data