Abdula_2314124

Untitled

Mar 25th, 2024
827
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.65 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. public class MoveCube : MonoBehaviour
  4. {
  5.     private void Update()
  6.     {
  7.         //PlayerPrefs.SetFloat("X", transform.position.x);
  8.         //PlayerPrefs.SetFloat("Y", transform.position.y);
  9.         //PlayerPrefs.SetFloat("Z", transform.position.z);
  10.  
  11.         if (Input.GetKeyDown(KeyCode.A))
  12.         {
  13.             LoadLastPosition();
  14.         }
  15.     }
  16.     private void LoadLastPosition()
  17.     {
  18.         var position = transform.position;
  19.         position.x = PlayerPrefs.GetFloat("X");
  20.         position.y = PlayerPrefs.GetFloat("Y");
  21.         position.z = PlayerPrefs.GetFloat("Z");
  22.         transform.position = position;
  23.     }
  24. }
  25.  
Advertisement
Add Comment
Please, Sign In to add comment