I am a Unity rookie.
What is wrong with my writing?
I can’t put in the script
I want him to correctly capture the information in the game archive.
To save and load
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Test : MonoBehaviour
{
public SaveGame sav = new SaveGame();
public void DoSave()
{
sav = sav.GetComponent();
PlayerPrefs.SetFloat(“PlayerX”, sav.transform.position.x);
PlayerPrefs.SetFloat(“PlayerY”, sav.transform.position.y);
}
public void DoLoad()
{
transform.position = new Vector2(PlayerPrefs.GetFloat(“PlayerX”), PlayerPrefs.GetFloat(“PlayerY”));
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SaveGame : MonoBehaviour
{
public float PosX = 0f;
public float PosY = 0f;
}