Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public class MoveCube : MonoBehaviour
- {
- private void Update()
- {
- //PlayerPrefs.SetFloat("X", transform.position.x);
- //PlayerPrefs.SetFloat("Y", transform.position.y);
- //PlayerPrefs.SetFloat("Z", transform.position.z);
- if (Input.GetKeyDown(KeyCode.A))
- {
- LoadLastPosition();
- }
- }
- private void LoadLastPosition()
- {
- var position = transform.position;
- position.x = PlayerPrefs.GetFloat("X");
- position.y = PlayerPrefs.GetFloat("Y");
- position.z = PlayerPrefs.GetFloat("Z");
- transform.position = position;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment