The following script can be attached to a GameObject to save it's position when it's Destroyed (this happens when the scene is changed, and when the application quits), and load it's position when the scene loads.
using UnityEngine;
public class SavePosition : MonoBehaviour
{
// Generate a unique ID for this GameObject.
public string guid = System.Guid.NewGuid().ToString();
void Awake()
{
transform.localPosition = ES3.Load<Vector3>(guid, transform.localPosition);
}
void OnDestroy()
{
ES3.Save<Vector3>(guid, transform.localPosition);
}
}
public class SavePosition : MonoBehaviour
{
// Generate a unique ID for this GameObject.
public string guid = System.Guid.NewGuid().ToString();
void Awake()
{
transform.localPosition = ES3.Load<Vector3>(guid, transform.localPosition);
}
void OnDestroy()
{
ES3.Save<Vector3>(guid, transform.localPosition);
}
}
So what code would i enter to have my players position?
Thank you
You would simply hook up the Save button to the OnDestroy method, and the Load button to the Awake method.
As the questions you are asking are general Unity programming questions rather than ones specific to Easy Save, I recommend you ask for more advice on the Unity forums. Unfortunately I'm only able to assist with things directly relating to Easy Save.
If I use this to save a unit's HP, Exp , etc. Will a bad actor be able to open the app and edit the save file directly ? I saw the encryption function but don't really want to mess up app store submission guidelines...
No file stored on a user's device is entirely secure. Even the Unity application itself can be tampered with. I recommend taking a look at the encryption guide for more information:
This tends to be less of an issue on iOS as the user would need to jailbreak their device in order to access the file. However, if security is of utmost importance to you then you would need to consult a security analyst as you would likely need a solution which is bespoke to your project.