Advertisement
Guest User

Untitled

a guest
Nov 14th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class changeScenes : MonoBehaviour
  6. {
  7. public static int iterator = 0;
  8.  
  9. // Start is called before the first frame update
  10. void Start()
  11. {
  12. Load();
  13. iterator++;
  14. }
  15. public void Load()
  16. {
  17. if (iterator!=0)
  18. {
  19. transform.position = new Vector3(PlayerPrefs.GetFloat("x"), PlayerPrefs.GetFloat("y"), PlayerPrefs.GetFloat("z"));
  20. transform.rotation = Quaternion.Euler(PlayerPrefs.GetFloat("rotx"),PlayerPrefs.GetFloat("roty"),PlayerPrefs.GetFloat("rotz"));
  21. }
  22. transform.position = new Vector3(transform.position.x, transform.position.y, transform.position.z);
  23. }
  24. public void Save()
  25. {
  26. PlayerPrefs.SetFloat("x", transform.position.x);
  27. PlayerPrefs.SetFloat("y", transform.position.y);
  28. PlayerPrefs.SetFloat("z", transform.position.z);
  29.  
  30. PlayerPrefs.SetFloat("rotx", transform.rotation.eulerAngles.x);
  31. PlayerPrefs.SetFloat("roty", transform.rotation.eulerAngles.y);
  32. PlayerPrefs.SetFloat("rotz", transform.rotation.eulerAngles.z);
  33. }
  34. // Update is called once per frame
  35. void Update()
  36. {
  37.  
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement