Скачал с Unity Assets
SaveGame
Вроде все сохраняет при выходе и восстанавливает при запуске но не расположение объектов(Появляются в нулевых координатах)(Сделал сохранение не Vector3 а отдельно каждую потому что не могу потом сделать new Vector3)
using UnityEngine;
using System.Collections;
using System.Linq;
public class SaveSystemSetup : MonoBehaviour {
[SerializeField] private string fileName = "Profile.bin"; // file to save with the specified resolution
[SerializeField] private bool dontDestroyOnLoad; // the object will move from one scene to another (you only need to add it once)
public GameObject towerprefab;
public int i, b;
public string namee, level, xc, yc, zc;
void Awake()
{
SaveSystem.Initialize(fileName);
if (dontDestroyOnLoad) DontDestroyOnLoad(transform.gameObject);
i = SaveSystem.GetInt("Numboftower");
b = 0;
while (b < i)
{
namee = "coord" + b.ToString();
level = "level" + b.ToString();
xc = "x" + b.ToString();
yc = "y" + b.ToString();
zc = "z" + b.ToString();
GameObject proj = Instantiate(towerprefab);
proj.transform.position = new Vector3(SaveSystem.GetFloat(xc), SaveSystem.GetFloat(yc), SaveSystem.GetFloat(zc));
proj.GetComponent<DiceLVL>().LVL = SaveSystem.GetInt(level);
//proj.GetComponent<DiceLVL>().Dannie = 1;
b++;
}
}
// if the object is present in all game scenes, auto save before exiting
// on some platforms there may not be an exit function, see the Unity help
void OnApplicationQuit()
{
SaveSystem.SaveToDisk();
SaveSystem.SetInt("Numboftower", GameObject.FindGameObjectsWithTag("Tower").Length);
i = GameObject.FindGameObjectsWithTag("Tower").Length;
b = 0;
while (b < i)
{
namee = "coord" + b.ToString();
level = "level" + b.ToString();
xc = "x" + b.ToString();
yc = "y" + b.ToString();
zc = "z" + b.ToString();
SaveSystem.SetFloat(xc, GameObject.FindGameObjectsWithTag("Tower")[b].transform.position.x);
SaveSystem.SetFloat(yc, GameObject.FindGameObjectsWithTag("Tower")[b].transform.position.y);
SaveSystem.SetFloat(zc, GameObject.FindGameObjectsWithTag("Tower")[b].transform.position.z);
SaveSystem.SetInt(level, GameObject.FindGameObjectsWithTag("Tower")[b].GetComponent<DiceLVL>().LVL);
b++;
}
}
}