I have a custom save/load interface for my game. I serialize all my data into .dat files and deserialize them when I load the data.
I’m using this code to get the directory information where all my save games are being stored:
enter code here //This function gets a list of all the files
public FileInfo[] GetDirectoryList()
{
string path = Application.persistentDataPath + savePath;
DirectoryInfo info = new DirectoryInfo(path);
FileInfo[] fileInfo = info.GetFiles();
return fileInfo;
}
It works perfectly on PC, but on Android it does not return anything. Nothing displays. When I use Astro File Viewer (external file browser) I can see that the save files are being placed where they should be. Is there a different method I should be using for Android? Why is this code not returning anything?
Also, to be clear, I have enabled “Write Access: External SD Card” in the Player Settings.
Just wondering, why not use PlayerPrefs instead for saving/loading? It will automatically sets the file depending on the platform the game is run on.
– zaid87I have large lists of data that need to be kept track of (hundreds of variables). Manually setting a player pref for each one would be too time consuming. Additionally, this generates a single file which can be transferred from machine to machine, which is ideal for my needs Additionally, my method allows a player to easily store multiple save profiles.
– BadAssGames