Skip to content

Commit c3aefac

Browse files
authored
Merge pull request #17 from coryleach/dev
Add Exists method to SaveLoadManager
2 parents 7781c6d + a2418a0 commit c3aefac

File tree

5 files changed

+302
-116
lines changed

5 files changed

+302
-116
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
</p>
1414
<h1 align="center">Gameframe.SaveLoad 👋</h1>
1515
16+
<!-- BADGE-START ->
17+
<img align="center" src="https://raw.githubusercontent.com/coryleach/UnityPackages/master/Documentation/GameframeFace.gif" />
18+
</p>
19+
<h1 align="center">Gameframe.SaveLoad 👋</h1>
20+
1621
<!-- BADGE-START -<!-- BADGE-END -->
1722

1823
Serialization helper utility that supports save, load and encryption.
@@ -22,15 +27,15 @@ Serialization helper utility that supports save, load and encryption.
2227
#### Using UnityPackageManager (for Unity 2019.3 or later)
2328
Open the package manager window (menu: Window > Package Manager)<br/>
2429
Select "Add package from git URL...", fill in the pop-up with the following link:<br/>
25-
https://github.com/coryleach/UnitySaveLoad.git#1.0.10<br/>
30+
https://github.com/coryleach/UnitySaveLoad.git#1.0.11<br/>
2631

2732
#### Using UnityPackageManager (for Unity 2019.1 or later)
2833

2934
Find the manifest.json file in the Packages folder of your project and edit it to look like this:
3035
```js
3136
{
3237
"dependencies": {
33-
"com.gameframe.saveload": "https://github.com/coryleach/UnitySaveLoad.git#1.0.10",
38+
"com.gameframe.saveload": "https://github.com/coryleach/UnitySaveLoad.git#1.0.11",
3439
...
3540
},
3641
}

Runtime/SaveLoadManager.cs

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,14 @@ public void Save(object obj, string filename, string folder = null)
7070
folder = defaultFolder;
7171
}
7272
var saveLoadMethod = GetSaveLoadMethod(saveMethod);
73-
SaveLoadUtility.Save(obj,saveLoadMethod,filename,folder, baseFolder);
73+
SaveLoadUtility.Save(obj, saveLoadMethod, filename, folder, baseFolder);
7474
}
7575

7676
/// <summary>
7777
/// Gets the list of save files that have been created
7878
/// </summary>
7979
/// <param name="folder">sub folder</param>
80-
/// <param name="extension"></param>
80+
/// <param name="extension">filter for files only with this extension if provided. Do not include the '.' in the string.</param>
8181
/// <param name="streamingAssets">Will use Application.streamingAssetsPath as base path if true otherwise Application.persistentDataPath</param>
8282
/// <returns>list of file names (excludes the path)</returns>
8383
public string[] GetFiles(string folder = null, string extension = null, bool streamingAssets = false)
@@ -86,15 +86,15 @@ public string[] GetFiles(string folder = null, string extension = null, bool str
8686
{
8787
folder = defaultFolder;
8888
}
89-
return SaveLoadUtility.GetSavedFiles(folder,baseFolder, extension, streamingAssets);
89+
return SaveLoadUtility.GetSavedFiles(folder, baseFolder, extension, streamingAssets);
9090
}
9191

9292
/// <summary>
9393
/// Gets the list of save files that have been created
9494
/// </summary>
9595
/// <param name="list">list to be populated with file names</param>
9696
/// <param name="folder">sub folder</param>
97-
/// <param name="extension"></param>
97+
/// <param name="extension">filter for files only with this extension if provided. Do not include the '.' in the string.</param>
9898
/// <param name="streamingAssets">Will use Application.streamingAssetsPath as base path if true otherwise Application.persistentDataPath</param>
9999
/// <returns>list of file names (excludes the path)</returns>
100100
public void GetFiles(List<string> list, string folder = null, string extension = null, bool streamingAssets = false)
@@ -103,8 +103,23 @@ public void GetFiles(List<string> list, string folder = null, string extension =
103103
{
104104
folder = defaultFolder;
105105
}
106-
107-
SaveLoadUtility.GetSavedFiles(list, folder,baseFolder, extension, streamingAssets);
106+
SaveLoadUtility.GetSavedFiles(list, folder, baseFolder, extension, streamingAssets);
107+
}
108+
109+
/// <summary>
110+
/// Checks if a given save file
111+
/// </summary>
112+
/// <param name="filename">name of the file to be checked</param>
113+
/// <param name="folder">subfolder within the base folder if any</param>
114+
/// <param name="streamingAssets">Will use Application.streamingAssetsPath as base path if true otherwise Application.persistentDataPath</param>
115+
/// <returns>True if file exists, false otherwise</returns>
116+
public bool Exists(string filename, string folder = null, bool streamingAssets = false)
117+
{
118+
if (string.IsNullOrEmpty(folder))
119+
{
120+
folder = defaultFolder;
121+
}
122+
return SaveLoadUtility.Exists(filename, folder, baseFolder, streamingAssets);
108123
}
109124

110125
/// <summary>

0 commit comments

Comments
 (0)