Skip to content

Commit 04a50f2

Browse files
author
Bronson Zgeb
committed
Refactored the SerializedSO
1 parent 79dbdb7 commit 04a50f2

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

UOP1_Project/Assets/ScriptableObjects/SaveSystem/SaveSystem.asset

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ MonoBehaviour:
1818
saveData:
1919
_locationId: d102ba8fe3b291249aeb9de4b95c1904
2020
_itemStacks:
21-
- Guid: 0a7c779a15b2c4143ae2068725b8ece9
22-
Amount: 1
21+
- itemGuid: 0a7c779a15b2c4143ae2068725b8ece9
22+
amount: 1

UOP1_Project/Assets/Scripts/SaveSystem/SaveSystem.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ private void CacheLoadLocations(GameSceneSO[] locationsToLoad, bool showLoadingS
2323
LocationSO locationSo = locationsToLoad[0] as LocationSO;
2424
if (locationSo)
2525
{
26-
saveData._locationId = locationSo.SerializableGuid;
26+
saveData._locationId = locationSo.Guid;
2727
}
2828

2929
SaveGame();
@@ -43,7 +43,7 @@ public void SaveGame()
4343
saveData._itemStacks.Clear();
4444
foreach (var itemStack in _playerInventory.Items)
4545
{
46-
saveData._itemStacks.Add(new SerializedItemStack(itemStack.Item.SerializableGuid, itemStack.Amount));
46+
saveData._itemStacks.Add(new SerializedItemStack(itemStack.Item.Guid, itemStack.Amount));
4747
}
4848

4949
if (FileManager.WriteToFile(saveFilename, saveData.ToJson()))

UOP1_Project/Assets/Scripts/SaveSystem/SerializableScriptableObject.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66

77
public class SerializableScriptableObject : ScriptableObject
88
{
9-
private string _serializableGuid;
10-
public string SerializableGuid => _serializableGuid;
9+
[SerializeField, HideInInspector] private string _guid;
10+
public string Guid => _guid;
1111

12+
#if UNITY_EDITOR
1213
void OnValidate()
1314
{
14-
#if UNITY_EDITOR
1515
var path = AssetDatabase.GetAssetPath(this);
16-
_serializableGuid = AssetDatabase.AssetPathToGUID(path);
17-
#endif
16+
_guid = AssetDatabase.AssetPathToGUID(path);
1817
}
18+
#endif
1919
}

0 commit comments

Comments
 (0)