From e87368d44183ccb703046eabe975df150d3fd1b1 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 17 Apr 2024 20:03:28 +0100 Subject: [PATCH] :package: 2.1.5 Release - Updated the initialization & reload checks in the back end of the asset. - [Community Reported]: Fixed a legacy code line in the settings provider class that was missed out of an earlier refactor. --- .../Inspectors/SaveObjectEditor.cs | 6 +- .../Inspectors/SettingsAssetRuntimeEditor.cs | 4 +- .../Profile Tab/SaveProfileListGUI.cs | 4 +- .../Menus & Shortcuts/SaveManagerMenuItems.cs | 2 +- .../Settings Provider.meta | 0 .../SaveManagerSettingsProvider.cs | 12 +- .../SaveManagerSettingsProvider.cs.meta | 0 .../Systems/Asset Index/AssetIndexHandler.cs | 22 +++- .../{Initialization.meta => Initialize.meta} | 0 .../Systems/Initialize/AssetInitializer.cs | 112 ++++++++++++++++++ .../AssetInitializer.cs.meta | 2 +- .../AssetReloadHandler.cs} | 89 ++++++-------- .../Initialize/AssetReloadHandler.cs.meta | 11 ++ .../Initialize/IAssetEditorInitialize.cs | 31 +++++ .../Initialize/IAssetEditorInitialize.cs.meta | 11 ++ .../Systems/Initialize/IAssetEditorReload.cs | 30 +++++ .../Initialize/IAssetEditorReload.cs.meta | 11 ++ .../Save Profiles/SaveProfileManager.cs | 2 +- .../Systems/Version Validator/VersionData.cs | 21 ++-- .../Version Validator/VersionEditorGUI.cs | 9 ++ .../Systems/Version Validator/VersionInfo.cs | 2 +- .../Version Validator/VersionPacket.cs | 2 +- .../Code/Editor/Utility/AssetVersionData.cs | 4 +- .../Editor Method Aid/InterfaceHelper.cs | 44 +++++++ .../Editor Method Aid/InterfaceHelper.cs.meta | 11 ++ .../ScriptableObjectInitialize.cs | 63 ++++++++++ .../ScriptableObjectInitialize.cs.meta | 11 ++ .../Scriptable Assets/ScriptableRef.cs | 68 ++++++++++- .../Code/Editor/Utility/UtilEditor.cs | 12 +- ...ntime.cs => AssetGlobalRuntimeSettings.cs} | 2 +- ...eta => AssetGlobalRuntimeSettings.cs.meta} | 0 .../Code/Runtime/Save Data/SaveData.cs | 2 +- .../Save Manager/Code/Runtime/SaveManager.cs | 10 +- .../Runtime/Saving/Automation/AutoSave.cs | 4 +- .../Saving/Encryption/EncryptionHandler.cs | 2 +- .../Encryption/Handlers/AesEncryption.cs | 4 +- .../Saving/Handlers/StandardSaveHandler.cs | 2 +- .../Runtime/Saving/Handlers/WebSaveHandler.cs | 2 +- 38 files changed, 520 insertions(+), 104 deletions(-) rename Carter Games/Save Manager/Code/Editor/{Custom Editors => }/Settings Provider.meta (100%) rename Carter Games/Save Manager/Code/Editor/{Custom Editors => }/Settings Provider/SaveManagerSettingsProvider.cs (97%) rename Carter Games/Save Manager/Code/Editor/{Custom Editors => }/Settings Provider/SaveManagerSettingsProvider.cs.meta (100%) rename Carter Games/Save Manager/Code/Editor/Systems/{Initialization.meta => Initialize.meta} (100%) create mode 100644 Carter Games/Save Manager/Code/Editor/Systems/Initialize/AssetInitializer.cs rename Carter Games/Save Manager/Code/Editor/Systems/{Initialization => Initialize}/AssetInitializer.cs.meta (86%) rename Carter Games/Save Manager/Code/Editor/Systems/{Initialization/AssetInitializer.cs => Initialize/AssetReloadHandler.cs} (51%) create mode 100644 Carter Games/Save Manager/Code/Editor/Systems/Initialize/AssetReloadHandler.cs.meta create mode 100644 Carter Games/Save Manager/Code/Editor/Systems/Initialize/IAssetEditorInitialize.cs create mode 100644 Carter Games/Save Manager/Code/Editor/Systems/Initialize/IAssetEditorInitialize.cs.meta create mode 100644 Carter Games/Save Manager/Code/Editor/Systems/Initialize/IAssetEditorReload.cs create mode 100644 Carter Games/Save Manager/Code/Editor/Systems/Initialize/IAssetEditorReload.cs.meta create mode 100644 Carter Games/Save Manager/Code/Editor/Utility/Editor Method Aid/InterfaceHelper.cs create mode 100644 Carter Games/Save Manager/Code/Editor/Utility/Editor Method Aid/InterfaceHelper.cs.meta create mode 100644 Carter Games/Save Manager/Code/Editor/Utility/Scriptable Assets/ScriptableObjectInitialize.cs create mode 100644 Carter Games/Save Manager/Code/Editor/Utility/Scriptable Assets/ScriptableObjectInitialize.cs.meta rename Carter Games/Save Manager/Code/Runtime/Data/{SettingsAssetRuntime.cs => AssetGlobalRuntimeSettings.cs} (99%) rename Carter Games/Save Manager/Code/Runtime/Data/{SettingsAssetRuntime.cs.meta => AssetGlobalRuntimeSettings.cs.meta} (100%) diff --git a/Carter Games/Save Manager/Code/Editor/Custom Editors/Inspectors/SaveObjectEditor.cs b/Carter Games/Save Manager/Code/Editor/Custom Editors/Inspectors/SaveObjectEditor.cs index 2252e1c..a3e222d 100644 --- a/Carter Games/Save Manager/Code/Editor/Custom Editors/Inspectors/SaveObjectEditor.cs +++ b/Carter Games/Save Manager/Code/Editor/Custom Editors/Inspectors/SaveObjectEditor.cs @@ -121,16 +121,16 @@ private void InitializeObject() serializedObject.Update(); // Adds to save data if it doesn't exist. - if (UtilEditor.Settings.SaveData.Data.Contains((SaveObject)target)) return; + if (UtilEditor.AssetGlobalRuntimeSettings.SaveData.Data.Contains((SaveObject)target)) return; - UtilEditor.Settings.SaveData.Data.Add((SaveObject)target); + UtilEditor.AssetGlobalRuntimeSettings.SaveData.Data.Add((SaveObject)target); propertiesLookup = new Dictionary() { { "SaveKey", serializedObject.Fp("saveKey") }, }; - EditorUtility.SetDirty(UtilEditor.Settings.SaveData); + EditorUtility.SetDirty(UtilEditor.AssetGlobalRuntimeSettings.SaveData); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); diff --git a/Carter Games/Save Manager/Code/Editor/Custom Editors/Inspectors/SettingsAssetRuntimeEditor.cs b/Carter Games/Save Manager/Code/Editor/Custom Editors/Inspectors/SettingsAssetRuntimeEditor.cs index 755b7da..0ae7973 100644 --- a/Carter Games/Save Manager/Code/Editor/Custom Editors/Inspectors/SettingsAssetRuntimeEditor.cs +++ b/Carter Games/Save Manager/Code/Editor/Custom Editors/Inspectors/SettingsAssetRuntimeEditor.cs @@ -29,7 +29,7 @@ namespace CarterGames.Assets.SaveManager.Editor /// /// A custom inspector for the settings asset scriptable object. /// - [CustomEditor(typeof(SettingsAssetRuntime))] + [CustomEditor(typeof(AssetGlobalRuntimeSettings))] public sealed class SettingsAssetRuntimeEditor : UnityEditor.Editor { /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── @@ -89,7 +89,7 @@ private static void DrawCogIcon() /// private void DrawDataSettings() { - UtilEditor.DrawSoScriptSection(target as SettingsAssetRuntime); + UtilEditor.DrawSoScriptSection(target as AssetGlobalRuntimeSettings); GUILayout.Space(12.5f); diff --git a/Carter Games/Save Manager/Code/Editor/Custom Editors/Windows/Editor Window/Sub Windows/Profile Tab/SaveProfileListGUI.cs b/Carter Games/Save Manager/Code/Editor/Custom Editors/Windows/Editor Window/Sub Windows/Profile Tab/SaveProfileListGUI.cs index f0e49dd..cdaf50e 100644 --- a/Carter Games/Save Manager/Code/Editor/Custom Editors/Windows/Editor Window/Sub Windows/Profile Tab/SaveProfileListGUI.cs +++ b/Carter Games/Save Manager/Code/Editor/Custom Editors/Windows/Editor Window/Sub Windows/Profile Tab/SaveProfileListGUI.cs @@ -214,7 +214,7 @@ private static void LoadSaveProfile(TextAsset data) } catch (Exception e) { - SmLog.Error($"Failed to read to {UtilEditor.Settings.SavePath} with the exception: {e}"); + SmLog.Error($"Failed to read to {UtilEditor.AssetGlobalRuntimeSettings.SavePath} with the exception: {e}"); return; } @@ -225,7 +225,7 @@ private static void LoadSaveProfile(TextAsset data) } // Updates the data in the editor & in the actual save. - EditorUtility.SetDirty(UtilEditor.Settings); + EditorUtility.SetDirty(UtilEditor.AssetGlobalRuntimeSettings); AssetDatabase.SaveAssets(); SaveManager.Save(); } diff --git a/Carter Games/Save Manager/Code/Editor/Menus & Shortcuts/SaveManagerMenuItems.cs b/Carter Games/Save Manager/Code/Editor/Menus & Shortcuts/SaveManagerMenuItems.cs index 5c1b412..03b0399 100644 --- a/Carter Games/Save Manager/Code/Editor/Menus & Shortcuts/SaveManagerMenuItems.cs +++ b/Carter Games/Save Manager/Code/Editor/Menus & Shortcuts/SaveManagerMenuItems.cs @@ -30,7 +30,7 @@ public static class SaveManagerMenuItems [MenuItem("Tools/Carter Games/Save Manager/Load Save Data", priority = 30)] public static void ManualLoadGame() { - SaveManager.Load(new StandardSaveHandler().LoadFromFile(UtilEditor.Settings.SavePath)); + SaveManager.Load(new StandardSaveHandler().LoadFromFile(UtilEditor.AssetGlobalRuntimeSettings.SavePath)); } diff --git a/Carter Games/Save Manager/Code/Editor/Custom Editors/Settings Provider.meta b/Carter Games/Save Manager/Code/Editor/Settings Provider.meta similarity index 100% rename from Carter Games/Save Manager/Code/Editor/Custom Editors/Settings Provider.meta rename to Carter Games/Save Manager/Code/Editor/Settings Provider.meta diff --git a/Carter Games/Save Manager/Code/Editor/Custom Editors/Settings Provider/SaveManagerSettingsProvider.cs b/Carter Games/Save Manager/Code/Editor/Settings Provider/SaveManagerSettingsProvider.cs similarity index 97% rename from Carter Games/Save Manager/Code/Editor/Custom Editors/Settings Provider/SaveManagerSettingsProvider.cs rename to Carter Games/Save Manager/Code/Editor/Settings Provider/SaveManagerSettingsProvider.cs index c9368ce..51cb694 100644 --- a/Carter Games/Save Manager/Code/Editor/Custom Editors/Settings Provider/SaveManagerSettingsProvider.cs +++ b/Carter Games/Save Manager/Code/Editor/Settings Provider/SaveManagerSettingsProvider.cs @@ -74,12 +74,12 @@ private static SerializedObject SettingsAssetObject { if (settingsAssetObject != null) return settingsAssetObject; - if (!UtilEditor.AssetIndex.Lookup.ContainsKey(typeof(SettingsAssetRuntime).ToString())) + if (!UtilEditor.AssetIndex.Lookup.ContainsKey(typeof(AssetGlobalRuntimeSettings).ToString())) { UtilEditor.Initialize(); } - settingsAssetObject = new SerializedObject(UtilEditor.AssetIndex.Lookup[typeof(SettingsAssetRuntime).ToString()][0]); + settingsAssetObject = new SerializedObject(UtilEditor.AssetIndex.Lookup[typeof(AssetGlobalRuntimeSettings).ToString()][0]); return settingsAssetObject; } } @@ -195,7 +195,7 @@ private static void DrawGeneralOptions() EditorUtility.RevealInFinder(UtilEditor.Settings.SavePath.Replace("save.sf", string.Empty)); } - GUI.backgroundColor = UtilEditor.SettingsAssetEditor.BackgroundColor; + GUI.backgroundColor = Color.white; EditorGUILayout.EndHorizontal(); #else @@ -205,12 +205,12 @@ private static void DrawGeneralOptions() if (GUILayout.Button(ExplorerButtonLabel)) { - if (!Directory.Exists(UtilEditor.Settings.SavePath)) + if (!Directory.Exists(UtilEditor.AssetGlobalRuntimeSettings.SavePath)) { - FileEditorUtil.CreateToDirectory(UtilEditor.Settings.SavePath); + FileEditorUtil.CreateToDirectory(UtilEditor.AssetGlobalRuntimeSettings.SavePath); } - EditorUtility.RevealInFinder(UtilEditor.Settings.SavePath.Replace("save.sf", string.Empty)); + EditorUtility.RevealInFinder(UtilEditor.AssetGlobalRuntimeSettings.SavePath.Replace("save.sf", string.Empty)); } GUI.backgroundColor = Color.white; diff --git a/Carter Games/Save Manager/Code/Editor/Custom Editors/Settings Provider/SaveManagerSettingsProvider.cs.meta b/Carter Games/Save Manager/Code/Editor/Settings Provider/SaveManagerSettingsProvider.cs.meta similarity index 100% rename from Carter Games/Save Manager/Code/Editor/Custom Editors/Settings Provider/SaveManagerSettingsProvider.cs.meta rename to Carter Games/Save Manager/Code/Editor/Settings Provider/SaveManagerSettingsProvider.cs.meta diff --git a/Carter Games/Save Manager/Code/Editor/Systems/Asset Index/AssetIndexHandler.cs b/Carter Games/Save Manager/Code/Editor/Systems/Asset Index/AssetIndexHandler.cs index a0865f0..38c45b5 100644 --- a/Carter Games/Save Manager/Code/Editor/Systems/Asset Index/AssetIndexHandler.cs +++ b/Carter Games/Save Manager/Code/Editor/Systems/Asset Index/AssetIndexHandler.cs @@ -31,13 +31,31 @@ namespace CarterGames.Assets.SaveManager.Editor /// /// Handles the setup of the asset index for runtime references to scriptable objects used for the asset. /// - public sealed class AssetIndexHandler : IPreprocessBuildWithReport + public sealed class AssetIndexHandler : IPreprocessBuildWithReport, IAssetEditorInitialize { /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── | Fields ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ - private const string AssetFilter = "t:savemanagerasset"; + private static readonly string AssetFilter = $"t:{nameof(SaveManagerAsset)}"; + + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | IAssetEditorInitialize Implementation + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + /// + /// Defines the order that this initializer run at. + /// + public int InitializeOrder => 1; + + + /// + /// Runs when the asset initialize flow is used. + /// + public void OnEditorInitialized() + { + UpdateIndex(); + } /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── | IPreprocessBuildWithReport Implementation diff --git a/Carter Games/Save Manager/Code/Editor/Systems/Initialization.meta b/Carter Games/Save Manager/Code/Editor/Systems/Initialize.meta similarity index 100% rename from Carter Games/Save Manager/Code/Editor/Systems/Initialization.meta rename to Carter Games/Save Manager/Code/Editor/Systems/Initialize.meta diff --git a/Carter Games/Save Manager/Code/Editor/Systems/Initialize/AssetInitializer.cs b/Carter Games/Save Manager/Code/Editor/Systems/Initialize/AssetInitializer.cs new file mode 100644 index 0000000..746f254 --- /dev/null +++ b/Carter Games/Save Manager/Code/Editor/Systems/Initialize/AssetInitializer.cs @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using System.Linq; +using System.Threading.Tasks; +using CarterGames.Common; +using UnityEditor; + +namespace CarterGames.Assets.SaveManager.Editor +{ + /// + /// Handles any initial listeners in the project for the asset. + /// + public static class AssetInitializer + { + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | Fields + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + // The key for if the asset has been initialized. + private static readonly string AssetInitializeKey = $"{FileEditorUtil.AssetName}_Session_EditorInitialize"; + + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | Properties + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + /// + /// Gets if the asset is initialized or not. + /// + public static bool IsInitialized + { + get => SessionState.GetBool(AssetInitializeKey, false); + private set => SessionState.SetBool(AssetInitializeKey, value); + } + + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | Events + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + /// + /// Is raised when the asset is initialized. + /// + public static readonly Evt Initialized = new Evt(); + + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | Methods + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + /// + /// Initializes the editor logic for the asset when called. + /// + [InitializeOnLoadMethod] + private static void TryInitialize() + { + if (IsInitialized) return; + InitializeEditorClasses(); + } + + + /// + /// Runs through all interfaces for initializing the editor asset logic and runs each in the defined order. + /// + private static async void InitializeEditorClasses() + { + var initClasses = InterfaceHelper.GetAllInterfacesInstancesOfType(); + + if (initClasses.Length > 0) + { + foreach (var init in initClasses.OrderBy(t => t.InitializeOrder)) + { + init.OnEditorInitialized(); + await Task.Yield(); + } + } + + OnAllClassesInitialized(); + } + + + /// + /// Runs any post initialize logic to complete the process. + /// + private static void OnAllClassesInitialized() + { + AssetDatabase.SaveAssets(); + AssetDatabase.Refresh(); + + IsInitialized = true; + Initialized.Raise(); + } + } +} \ No newline at end of file diff --git a/Carter Games/Save Manager/Code/Editor/Systems/Initialization/AssetInitializer.cs.meta b/Carter Games/Save Manager/Code/Editor/Systems/Initialize/AssetInitializer.cs.meta similarity index 86% rename from Carter Games/Save Manager/Code/Editor/Systems/Initialization/AssetInitializer.cs.meta rename to Carter Games/Save Manager/Code/Editor/Systems/Initialize/AssetInitializer.cs.meta index a327234..65041ca 100644 --- a/Carter Games/Save Manager/Code/Editor/Systems/Initialization/AssetInitializer.cs.meta +++ b/Carter Games/Save Manager/Code/Editor/Systems/Initialize/AssetInitializer.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: cd1bf714b881b0b41a5b5de7d92127ff +guid: f14ebca0b0fc429393618523084297de MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Carter Games/Save Manager/Code/Editor/Systems/Initialization/AssetInitializer.cs b/Carter Games/Save Manager/Code/Editor/Systems/Initialize/AssetReloadHandler.cs similarity index 51% rename from Carter Games/Save Manager/Code/Editor/Systems/Initialization/AssetInitializer.cs rename to Carter Games/Save Manager/Code/Editor/Systems/Initialize/AssetReloadHandler.cs index e3438d2..3c7ebe4 100644 --- a/Carter Games/Save Manager/Code/Editor/Systems/Initialization/AssetInitializer.cs +++ b/Carter Games/Save Manager/Code/Editor/Systems/Initialize/AssetReloadHandler.cs @@ -21,77 +21,66 @@ * THE SOFTWARE. */ -using System.IO; -using System.Reflection; +using System.Threading.Tasks; +using CarterGames.Common; using UnityEditor; +using UnityEditor.Callbacks; namespace CarterGames.Assets.SaveManager.Editor { /// - /// Handles the auto setup of the save manager when the assets are changed in the project. + /// Handles any reload listeners in the project for the asset. /// - public class AssetInitializer : AssetPostprocessor + public static class AssetReloadHandler { /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── - | Methods + | Events ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ /// - /// Runs after assets have imported / script reload etc at a safe time to edit assets. - /// - private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, - string[] movedFromAssetPaths) - { - TryInitialize(); - } - - - /// - /// Initializes the save data on project load - /// - [InitializeOnLoadMethod] - private static void TryInitSave() - { - if (SessionState.GetBool("HasLoaded", false)) return; - DelayUpdate(); - } - - - /// - /// Listen for a delayed update to ensure the editor is all loaded before loading data. + /// Raises when the reload has occured. /// - private static void DelayUpdate() - { - EditorApplication.delayCall -= LoadOnProjectOpen; - EditorApplication.delayCall += LoadOnProjectOpen; - } - - + public static readonly Evt Reloaded = new Evt(); + + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | Methods + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + /// - /// Loads the latest data into the save system for use. + /// Add subscription to the delay call when scripts reload. /// - private static void LoadOnProjectOpen() + [DidReloadScripts] + private static void FireReloadCalls() { - EditorApplication.delayCall -= LoadOnProjectOpen; - - // Initializes the Save Manager and loads the data for use. - typeof(SaveManager).GetMethod("Initialize", BindingFlags.NonPublic | BindingFlags.Static)?.Invoke(null, null); + if (EditorApplication.isCompiling || EditorApplication.isUpdating) + { + EditorApplication.delayCall -= CallListeners; + EditorApplication.delayCall += CallListeners; + return; + } - SessionState.SetBool("HasLoaded", true); + EditorApplication.delayCall -= CallListeners; + EditorApplication.delayCall += CallListeners; } - + /// - /// Creates the scriptable objects for the asset if they don't exist yet. + /// Updates all the listeners when called. /// - private static void TryInitialize() + private static async void CallListeners() { - LegacyIndexRemovalTool.TryRemoveOldIndex(); + var reloadClasses = InterfaceHelper.GetAllInterfacesInstancesOfType(); + + if (reloadClasses.Length > 0) + { + foreach (var init in reloadClasses) + { + init.OnEditorReloaded(); + await Task.Yield(); + } + } - if (UtilEditor.HasInitialized) return; - UtilEditor.Initialize(); - AssetDatabase.SaveAssets(); - AssetDatabase.Refresh(); + Reloaded.Raise(); } } -} +} \ No newline at end of file diff --git a/Carter Games/Save Manager/Code/Editor/Systems/Initialize/AssetReloadHandler.cs.meta b/Carter Games/Save Manager/Code/Editor/Systems/Initialize/AssetReloadHandler.cs.meta new file mode 100644 index 0000000..ce3076e --- /dev/null +++ b/Carter Games/Save Manager/Code/Editor/Systems/Initialize/AssetReloadHandler.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d685045b14f7442687bc280348cd382a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 40ab1dfa65cdd6247bb1a3d4ea54901c, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Carter Games/Save Manager/Code/Editor/Systems/Initialize/IAssetEditorInitialize.cs b/Carter Games/Save Manager/Code/Editor/Systems/Initialize/IAssetEditorInitialize.cs new file mode 100644 index 0000000..1897fd9 --- /dev/null +++ b/Carter Games/Save Manager/Code/Editor/Systems/Initialize/IAssetEditorInitialize.cs @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +namespace CarterGames.Assets.SaveManager.Editor +{ + public interface IAssetEditorInitialize + { + int InitializeOrder { get; } + void OnEditorInitialized(); + } +} \ No newline at end of file diff --git a/Carter Games/Save Manager/Code/Editor/Systems/Initialize/IAssetEditorInitialize.cs.meta b/Carter Games/Save Manager/Code/Editor/Systems/Initialize/IAssetEditorInitialize.cs.meta new file mode 100644 index 0000000..43d500c --- /dev/null +++ b/Carter Games/Save Manager/Code/Editor/Systems/Initialize/IAssetEditorInitialize.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c43d7778b4104adabce50d37be88613b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 40ab1dfa65cdd6247bb1a3d4ea54901c, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Carter Games/Save Manager/Code/Editor/Systems/Initialize/IAssetEditorReload.cs b/Carter Games/Save Manager/Code/Editor/Systems/Initialize/IAssetEditorReload.cs new file mode 100644 index 0000000..cf03dc5 --- /dev/null +++ b/Carter Games/Save Manager/Code/Editor/Systems/Initialize/IAssetEditorReload.cs @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +namespace CarterGames.Assets.SaveManager.Editor +{ + public interface IAssetEditorReload + { + void OnEditorReloaded(); + } +} \ No newline at end of file diff --git a/Carter Games/Save Manager/Code/Editor/Systems/Initialize/IAssetEditorReload.cs.meta b/Carter Games/Save Manager/Code/Editor/Systems/Initialize/IAssetEditorReload.cs.meta new file mode 100644 index 0000000..0a4ee49 --- /dev/null +++ b/Carter Games/Save Manager/Code/Editor/Systems/Initialize/IAssetEditorReload.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7a70ec3f4a8d4507b41326b23b933626 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 40ab1dfa65cdd6247bb1a3d4ea54901c, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Carter Games/Save Manager/Code/Editor/Systems/Save Profiles/SaveProfileManager.cs b/Carter Games/Save Manager/Code/Editor/Systems/Save Profiles/SaveProfileManager.cs index 4d0abd6..0b1ef38 100644 --- a/Carter Games/Save Manager/Code/Editor/Systems/Save Profiles/SaveProfileManager.cs +++ b/Carter Games/Save Manager/Code/Editor/Systems/Save Profiles/SaveProfileManager.cs @@ -37,7 +37,7 @@ public static void CaptureProfile(string savePath, string captureName) { var profileSavePath = $"{savePath}/{captureName}.json"; - var json = JsonUtility.ToJson(UtilEditor.Settings.SaveData.SerializableData, true); + var json = JsonUtility.ToJson(UtilEditor.AssetGlobalRuntimeSettings.SaveData.SerializableData, true); FileEditorUtil.CreateToDirectory(profileSavePath); AssetDatabase.SaveAssets(); diff --git a/Carter Games/Save Manager/Code/Editor/Systems/Version Validator/VersionData.cs b/Carter Games/Save Manager/Code/Editor/Systems/Version Validator/VersionData.cs index c4de9d1..29c46e7 100644 --- a/Carter Games/Save Manager/Code/Editor/Systems/Version Validator/VersionData.cs +++ b/Carter Games/Save Manager/Code/Editor/Systems/Version Validator/VersionData.cs @@ -90,12 +90,14 @@ public string ReleaseDate /// If the entry is a match or not on all values (major/minor/patch). public bool Match(string toCompare) { - var aVN = VersionNumber; - var bVN = new VersionNumber(toCompare); + var current = VersionNumber; + var remote = new VersionNumber(toCompare); - return aVN.Major.Equals(bVN.Major) && aVN.Minor.Equals(bVN.Minor) && aVN.Patch.Equals(bVN.Patch); + return current.Major.Equals(remote.Major) && + current.Minor.Equals(remote.Minor) && + current.Patch.Equals(remote.Patch); } - + /// /// Gets if the entry is a higher version than the converted version. @@ -104,15 +106,20 @@ public bool Match(string toCompare) /// If the entry is greater on any (major/minor/patch) value. public bool IsHigherVersion(string toCompare) { - var aVN = VersionNumber; - var bVN = new VersionNumber(toCompare); + var current = VersionNumber; + var remote = new VersionNumber(toCompare); if (Match(toCompare)) { return false; } - return (aVN.Major < bVN.Major) || (aVN.Minor < bVN.Minor) || (aVN.Patch < bVN.Patch); + if (current.Major < remote.Major) return true; + if (current.Major.Equals(remote.Major) && current.Minor < remote.Minor) return true; + + return current.Major.Equals(remote.Major) && + current.Minor.Equals(remote.Minor) && + current.Patch < remote.Patch; } } } \ No newline at end of file diff --git a/Carter Games/Save Manager/Code/Editor/Systems/Version Validator/VersionEditorGUI.cs b/Carter Games/Save Manager/Code/Editor/Systems/Version Validator/VersionEditorGUI.cs index 709077a..aebe569 100644 --- a/Carter Games/Save Manager/Code/Editor/Systems/Version Validator/VersionEditorGUI.cs +++ b/Carter Games/Save Manager/Code/Editor/Systems/Version Validator/VersionEditorGUI.cs @@ -56,6 +56,15 @@ public static void ShowResponseDialogue(bool showIfUptoDate = true) { VersionChecker.ResponseReceived.RemoveAnonymous("versionCheckManual"); + if (VersionChecker.Versions.Data == null) + { + EditorUtility.DisplayDialog("Update Checker", + $"Either you are offline or the system for version checking is broken or missing an entry.", + "Continue"); + + return; + } + if (VersionChecker.IsNewerVersion) { if (!showIfUptoDate) return; diff --git a/Carter Games/Save Manager/Code/Editor/Systems/Version Validator/VersionInfo.cs b/Carter Games/Save Manager/Code/Editor/Systems/Version Validator/VersionInfo.cs index 9a06079..760711b 100644 --- a/Carter Games/Save Manager/Code/Editor/Systems/Version Validator/VersionInfo.cs +++ b/Carter Games/Save Manager/Code/Editor/Systems/Version Validator/VersionInfo.cs @@ -41,7 +41,7 @@ public static class VersionInfo /// /// The download Url for the latest version of this package. /// - public const string DownloadBaseUrl = "https://github.com/CarterGames/Common/releases/tag/"; + public const string DownloadBaseUrl = "https://github.com/CarterGames/SaveManager/releases/tag/"; /// diff --git a/Carter Games/Save Manager/Code/Editor/Systems/Version Validator/VersionPacket.cs b/Carter Games/Save Manager/Code/Editor/Systems/Version Validator/VersionPacket.cs index 8f3a554..744b8cc 100644 --- a/Carter Games/Save Manager/Code/Editor/Systems/Version Validator/VersionPacket.cs +++ b/Carter Games/Save Manager/Code/Editor/Systems/Version Validator/VersionPacket.cs @@ -46,6 +46,6 @@ public sealed class VersionPacket /// /// The data received for this package. /// - public VersionData Data => data.First(t => t.Key.Equals(VersionInfo.Key)); + public VersionData Data => data.FirstOrDefault(t => t.Key.Equals(VersionInfo.Key)); } } \ No newline at end of file diff --git a/Carter Games/Save Manager/Code/Editor/Utility/AssetVersionData.cs b/Carter Games/Save Manager/Code/Editor/Utility/AssetVersionData.cs index fa244cf..a9eafc0 100644 --- a/Carter Games/Save Manager/Code/Editor/Utility/AssetVersionData.cs +++ b/Carter Games/Save Manager/Code/Editor/Utility/AssetVersionData.cs @@ -31,7 +31,7 @@ public static class AssetVersionData /// /// The version number of the asset. /// - public static string VersionNumber => "2.1.4"; + public static string VersionNumber => "2.1.5"; /// @@ -40,6 +40,6 @@ public static class AssetVersionData /// /// Asset owner is in the UK, so its D/M/Y format. /// - public static string ReleaseDate => "19/03/2024"; + public static string ReleaseDate => "17/04/2024"; } } \ No newline at end of file diff --git a/Carter Games/Save Manager/Code/Editor/Utility/Editor Method Aid/InterfaceHelper.cs b/Carter Games/Save Manager/Code/Editor/Utility/Editor Method Aid/InterfaceHelper.cs new file mode 100644 index 0000000..857c742 --- /dev/null +++ b/Carter Games/Save Manager/Code/Editor/Utility/Editor Method Aid/InterfaceHelper.cs @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using System; +using System.Linq; + +namespace CarterGames.Assets.SaveManager.Editor +{ + public static class InterfaceHelper + { + /// + /// Gets all the interface implementations and returns the result (Editor Only) + /// + /// An Array of the interface type + public static T[] GetAllInterfacesInstancesOfType() + { + var types = AppDomain.CurrentDomain.GetAssemblies() + .SelectMany(x => x.GetTypes()) + .Where(x => x.IsClass && typeof(T).IsAssignableFrom(x)); + + return types.Select(type => (T)Activator.CreateInstance(type)).ToArray(); + } + } +} \ No newline at end of file diff --git a/Carter Games/Save Manager/Code/Editor/Utility/Editor Method Aid/InterfaceHelper.cs.meta b/Carter Games/Save Manager/Code/Editor/Utility/Editor Method Aid/InterfaceHelper.cs.meta new file mode 100644 index 0000000..aeb9caa --- /dev/null +++ b/Carter Games/Save Manager/Code/Editor/Utility/Editor Method Aid/InterfaceHelper.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8be781c060ce41e18bc659ba153fe286 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 40ab1dfa65cdd6247bb1a3d4ea54901c, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Carter Games/Save Manager/Code/Editor/Utility/Scriptable Assets/ScriptableObjectInitialize.cs b/Carter Games/Save Manager/Code/Editor/Utility/Scriptable Assets/ScriptableObjectInitialize.cs new file mode 100644 index 0000000..127abe6 --- /dev/null +++ b/Carter Games/Save Manager/Code/Editor/Utility/Scriptable Assets/ScriptableObjectInitialize.cs @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +namespace CarterGames.Assets.SaveManager.Editor +{ + /// + /// Handles any logic for generating/updating the scriptable objects for the asset where needed. + /// + public class ScriptableObjectInitialize : IAssetEditorInitialize, IAssetEditorReload + { + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | IAssetEditorInitialize + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + /// + /// Defines the order that this initializer run at. + /// + public int InitializeOrder => -1; + + + /// + /// Runs when the asset initialize flow is used. + /// + public void OnEditorInitialized() + { + if (ScriptableRef.HasAllAssets) return; + ScriptableRef.TryCreateAssets(); + } + + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | IAssetEditorReload + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + /// + /// Runs when the asset reload flow is used. + /// + public void OnEditorReloaded() + { + if (ScriptableRef.HasAllAssets) return; + ScriptableRef.TryCreateAssets(); + } + } +} \ No newline at end of file diff --git a/Carter Games/Save Manager/Code/Editor/Utility/Scriptable Assets/ScriptableObjectInitialize.cs.meta b/Carter Games/Save Manager/Code/Editor/Utility/Scriptable Assets/ScriptableObjectInitialize.cs.meta new file mode 100644 index 0000000..4c67c87 --- /dev/null +++ b/Carter Games/Save Manager/Code/Editor/Utility/Scriptable Assets/ScriptableObjectInitialize.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 260a7583ac83448d89241a21c2e415f5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 40ab1dfa65cdd6247bb1a3d4ea54901c, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Carter Games/Save Manager/Code/Editor/Utility/Scriptable Assets/ScriptableRef.cs b/Carter Games/Save Manager/Code/Editor/Utility/Scriptable Assets/ScriptableRef.cs index 4e017f7..b203656 100644 --- a/Carter Games/Save Manager/Code/Editor/Utility/Scriptable Assets/ScriptableRef.cs +++ b/Carter Games/Save Manager/Code/Editor/Utility/Scriptable Assets/ScriptableRef.cs @@ -46,7 +46,7 @@ public static class ScriptableRef // Asset Filters /* ────────────────────────────────────────────────────────────────────────────────────────────────────────── */ - private static readonly string RuntimeSettingsFilter = $"t:{typeof(SettingsAssetRuntime).FullName}"; + private static readonly string RuntimeSettingsFilter = $"t:{typeof(AssetGlobalRuntimeSettings).FullName}"; private static readonly string AssetIndexFilter = $"t:{typeof(AssetIndex).FullName}"; private static readonly string SaveProfilesStoreFilter = $"t:{typeof(SaveProfilesStore).FullName}"; private static readonly string SaveDataFilter = $"t:{typeof(SaveData).FullName}"; @@ -55,7 +55,7 @@ public static class ScriptableRef // Asset Caches /* ────────────────────────────────────────────────────────────────────────────────────────────────────────── */ - private static SettingsAssetRuntime settingsAssetRuntimeCache; + private static AssetGlobalRuntimeSettings assetGlobalRuntimeSettingsCache; private static AssetIndex assetIndexCache; private static SaveProfilesStore saveProfilesStoreCache; private static SaveData saveDataCache; @@ -99,8 +99,8 @@ public static class ScriptableRef /// /// The runtime settings for the asset. /// - public static SettingsAssetRuntime RuntimeSettings => - FileEditorUtil.CreateSoGetOrAssignAssetCache(ref settingsAssetRuntimeCache, RuntimeSettingsFilter, SettingsAssetPath, AssetName, $"{AssetName}/Data/Runtime Settings.asset"); + public static AssetGlobalRuntimeSettings RuntimeAssetGlobalRuntimeSettings => + FileEditorUtil.CreateSoGetOrAssignAssetCache(ref assetGlobalRuntimeSettingsCache, RuntimeSettingsFilter, SettingsAssetPath, AssetName, $"{AssetName}/Data/Runtime Settings.asset"); /// @@ -130,7 +130,7 @@ public static class ScriptableRef /// The runtime SerializedObject for the asset. /// public static SerializedObject RuntimeSettingsObject => - FileEditorUtil.CreateGetOrAssignSerializedObjectCache(ref settingsAssetRuntimeObjectCache, RuntimeSettings); + FileEditorUtil.CreateGetOrAssignSerializedObjectCache(ref settingsAssetRuntimeObjectCache, RuntimeAssetGlobalRuntimeSettings); // Assets Initialized Check /* ────────────────────────────────────────────────────────────────────────────────────────────────────────── */ @@ -142,5 +142,63 @@ public static class ScriptableRef File.Exists(AssetIndexPath) && File.Exists(SettingsAssetPath) && File.Exists(EncryptionKeyAssetPath) && File.Exists(SaveDataPath) && File.Exists(CapturesObjectAssetPath); + + + /// + /// Tries to create any missing assets when called. + /// + public static void TryCreateAssets() + { + if (assetIndexCache == null) + { + FileEditorUtil.CreateSoGetOrAssignAssetCache( + ref assetIndexCache, + AssetIndexFilter, + AssetIndexPath, + AssetName, $"{AssetName}/Resources/Asset Index.asset"); + } + + + if (assetGlobalRuntimeSettingsCache == null) + { + FileEditorUtil.CreateSoGetOrAssignAssetCache( + ref assetGlobalRuntimeSettingsCache, + RuntimeSettingsFilter, + SettingsAssetPath, + AssetName, $"{AssetName}/Data/Runtime Settings.asset"); + } + + + if (saveProfilesStoreCache == null) + { + FileEditorUtil.CreateSoGetOrAssignAssetCache( + ref saveProfilesStoreCache, + SaveProfilesStoreFilter, + CapturesObjectAssetPath, + AssetName, $"{AssetName}/Data/Save Profiles Container.asset"); + } + + + if (encryptionKeyAssetCache == null) + { + FileEditorUtil.CreateSoGetOrAssignAssetCache( + ref encryptionKeyAssetCache, + SaveDataEncryptionKeyFilter, + EncryptionKeyAssetPath, + AssetName, $"{AssetName}/Data/Encryption Key.asset"); + + } + + + if (saveDataCache == null) + { + FileEditorUtil.CreateSoGetOrAssignAssetCache( + ref saveDataCache, + SaveDataFilter, + SaveDataPath, + AssetName, $"{AssetName}/Data/Save Data.asset"); + + } + } } } \ No newline at end of file diff --git a/Carter Games/Save Manager/Code/Editor/Utility/UtilEditor.cs b/Carter Games/Save Manager/Code/Editor/Utility/UtilEditor.cs index 61e1b9b..b74cd1a 100644 --- a/Carter Games/Save Manager/Code/Editor/Utility/UtilEditor.cs +++ b/Carter Games/Save Manager/Code/Editor/Utility/UtilEditor.cs @@ -75,7 +75,7 @@ public static class UtilEditor // Asset Caches /* ────────────────────────────────────────────────────────────────────────────────────────────────────────── */ - private static SettingsAssetRuntime settingsCache; + private static AssetGlobalRuntimeSettings assetGlobalRuntimeSettingsCache; private static SerializedObject settingsObjectCache; private static SerializedObject editorSettingsObjectCache; private static SaveProfilesStore saveProfilesStoreCache; @@ -207,7 +207,7 @@ public static bool HasInitialized /// /// Gets/Sets the save manager settings asset. /// - public static SettingsAssetRuntime Settings => ScriptableRef.RuntimeSettings; + public static AssetGlobalRuntimeSettings AssetGlobalRuntimeSettings => ScriptableRef.RuntimeAssetGlobalRuntimeSettings; /// @@ -343,9 +343,9 @@ public static void Initialize() assetIndexCache = AssetIndex; } - if (settingsCache == null) + if (assetGlobalRuntimeSettingsCache == null) { - settingsCache = Settings; + assetGlobalRuntimeSettingsCache = AssetGlobalRuntimeSettings; } if (saveDataCache == null) @@ -370,7 +370,7 @@ public static void Initialize() AssetDatabase.Refresh(); - var dataObj = new SerializedObject(Settings); + var dataObj = new SerializedObject(AssetGlobalRuntimeSettings); dataObj.Fp("saveDataAsset").objectReferenceValue = SaveData; dataObj.ApplyModifiedProperties(); dataObj.Update(); @@ -393,7 +393,7 @@ public static void Initialize() dataObj.ApplyModifiedProperties(); dataObj.Update(); - Settings.Initialize(); + AssetGlobalRuntimeSettings.Initialize(); if (!EncryptionKeyAsset.HasKey) { diff --git a/Carter Games/Save Manager/Code/Runtime/Data/SettingsAssetRuntime.cs b/Carter Games/Save Manager/Code/Runtime/Data/AssetGlobalRuntimeSettings.cs similarity index 99% rename from Carter Games/Save Manager/Code/Runtime/Data/SettingsAssetRuntime.cs rename to Carter Games/Save Manager/Code/Runtime/Data/AssetGlobalRuntimeSettings.cs index b5f5149..7ea8580 100644 --- a/Carter Games/Save Manager/Code/Runtime/Data/SettingsAssetRuntime.cs +++ b/Carter Games/Save Manager/Code/Runtime/Data/AssetGlobalRuntimeSettings.cs @@ -31,7 +31,7 @@ namespace CarterGames.Assets.SaveManager /// Handles the runtime settings for the save manager asset. /// [CreateAssetMenu(fileName = "Runtime Settings", menuName = "Carter Games/Save Manager/Runtime Settings Asset", order = 2)] - public sealed class SettingsAssetRuntime : SaveManagerAsset + public sealed class AssetGlobalRuntimeSettings : SaveManagerAsset { /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── | Fields diff --git a/Carter Games/Save Manager/Code/Runtime/Data/SettingsAssetRuntime.cs.meta b/Carter Games/Save Manager/Code/Runtime/Data/AssetGlobalRuntimeSettings.cs.meta similarity index 100% rename from Carter Games/Save Manager/Code/Runtime/Data/SettingsAssetRuntime.cs.meta rename to Carter Games/Save Manager/Code/Runtime/Data/AssetGlobalRuntimeSettings.cs.meta diff --git a/Carter Games/Save Manager/Code/Runtime/Save Data/SaveData.cs b/Carter Games/Save Manager/Code/Runtime/Save Data/SaveData.cs index b7b001b..08a8d14 100644 --- a/Carter Games/Save Manager/Code/Runtime/Save Data/SaveData.cs +++ b/Carter Games/Save Manager/Code/Runtime/Save Data/SaveData.cs @@ -73,7 +73,7 @@ public SerializableDictionary> Se foreach (var v in data.Values) { - converted.Add(v.key, JsonUtility.ToJson(v, AssetAccessor.GetAsset().Prettify)); + converted.Add(v.key, JsonUtility.ToJson(v, AssetAccessor.GetAsset().Prettify)); } items.Add(saveValue.SaveKey, converted); diff --git a/Carter Games/Save Manager/Code/Runtime/SaveManager.cs b/Carter Games/Save Manager/Code/Runtime/SaveManager.cs index 9166246..5779eed 100644 --- a/Carter Games/Save Manager/Code/Runtime/SaveManager.cs +++ b/Carter Games/Save Manager/Code/Runtime/SaveManager.cs @@ -40,7 +40,7 @@ public static class SaveManager ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ // The actual save data asset holding the data in the project. - private static SaveData SaveData => AssetAccessor.GetAsset().SaveData; + private static SaveData SaveData => AssetAccessor.GetAsset().SaveData; // The load handler cache for the save manager. @@ -74,19 +74,19 @@ public static class SaveManager /// /// Gets the save path for the current save setup. /// - private static string SavePath => AssetAccessor.GetAsset().SavePath; + private static string SavePath => AssetAccessor.GetAsset().SavePath; /// /// Gets the save path for the current save setup. /// - private static bool Prettify => AssetAccessor.GetAsset().Prettify; + private static bool Prettify => AssetAccessor.GetAsset().Prettify; /// /// Gets the current encryption setting setup. /// - private static EncryptionOption EncryptionSetting => AssetAccessor.GetAsset().Encryption; + private static EncryptionOption EncryptionSetting => AssetAccessor.GetAsset().Encryption; /// @@ -146,7 +146,7 @@ private static void Initialize() if (IsInitialized) return; // Makes the save file if it doesn't exist yet, as I somehow missed this check on load otherwise. - if (!File.Exists(AssetAccessor.GetAsset().SavePath)) + if (!File.Exists(AssetAccessor.GetAsset().SavePath)) { Save(); } diff --git a/Carter Games/Save Manager/Code/Runtime/Saving/Automation/AutoSave.cs b/Carter Games/Save Manager/Code/Runtime/Saving/Automation/AutoSave.cs index 184c404..1359667 100644 --- a/Carter Games/Save Manager/Code/Runtime/Saving/Automation/AutoSave.cs +++ b/Carter Games/Save Manager/Code/Runtime/Saving/Automation/AutoSave.cs @@ -46,7 +46,7 @@ public class AutoSave : MonoBehaviour [RuntimeInitializeOnLoadMethod] private static void SetupInstance() { - if (!AssetAccessor.GetAsset().AutoSave) return; + if (!AssetAccessor.GetAsset().AutoSave) return; if (instance != null) return; var obj = new GameObject("Auto Save (Save Manager)"); @@ -64,7 +64,7 @@ private static void SetupInstance() /// private void OnApplicationQuit() { - if (!AssetAccessor.GetAsset().AutoSave) return; + if (!AssetAccessor.GetAsset().AutoSave) return; SaveManager.Save(false); } diff --git a/Carter Games/Save Manager/Code/Runtime/Saving/Encryption/EncryptionHandler.cs b/Carter Games/Save Manager/Code/Runtime/Saving/Encryption/EncryptionHandler.cs index 1045341..f16093b 100644 --- a/Carter Games/Save Manager/Code/Runtime/Saving/Encryption/EncryptionHandler.cs +++ b/Carter Games/Save Manager/Code/Runtime/Saving/Encryption/EncryptionHandler.cs @@ -68,7 +68,7 @@ private static IEncryptionHandler GetHandler(EncryptionOption encryptionOption, /// The json string to use. public static void EncryptData(string jsonData) { - switch (AssetAccessor.GetAsset().Encryption) + switch (AssetAccessor.GetAsset().Encryption) { case EncryptionOption.Aes: GetHandler(EncryptionOption.Aes, typeof(AesEncryption)).Encrypt(jsonData); diff --git a/Carter Games/Save Manager/Code/Runtime/Saving/Encryption/Handlers/AesEncryption.cs b/Carter Games/Save Manager/Code/Runtime/Saving/Encryption/Handlers/AesEncryption.cs index d0c537c..5727c79 100644 --- a/Carter Games/Save Manager/Code/Runtime/Saving/Encryption/Handlers/AesEncryption.cs +++ b/Carter Games/Save Manager/Code/Runtime/Saving/Encryption/Handlers/AesEncryption.cs @@ -36,7 +36,7 @@ public void Encrypt(string jsonData) { var iAes = Aes.Create(); - using (var fStream = new FileStream(AssetAccessor.GetAsset().SavePath, FileMode.OpenOrCreate)) + using (var fStream = new FileStream(AssetAccessor.GetAsset().SavePath, FileMode.OpenOrCreate)) { if (!AssetAccessor.GetAsset().HasKey) { @@ -71,7 +71,7 @@ public void Encrypt(string jsonData) /// The decrypted data. public string Decrypt() { - var fStream = new FileStream(AssetAccessor.GetAsset().SavePath, FileMode.Open, FileAccess.Read, FileShare.Read); + var fStream = new FileStream(AssetAccessor.GetAsset().SavePath, FileMode.Open, FileAccess.Read, FileShare.Read); var oAes = Aes.Create(); oAes.Key = AssetAccessor.GetAsset().SaveEncryptionKey; diff --git a/Carter Games/Save Manager/Code/Runtime/Saving/Handlers/StandardSaveHandler.cs b/Carter Games/Save Manager/Code/Runtime/Saving/Handlers/StandardSaveHandler.cs index 566a00e..aa95027 100644 --- a/Carter Games/Save Manager/Code/Runtime/Saving/Handlers/StandardSaveHandler.cs +++ b/Carter Games/Save Manager/Code/Runtime/Saving/Handlers/StandardSaveHandler.cs @@ -94,7 +94,7 @@ public SerializableDictionary> Lo { try { - using (var stream = new FileStream(AssetAccessor.GetAsset().SavePath, + using (var stream = new FileStream(AssetAccessor.GetAsset().SavePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite)) { using (var reader = new StreamReader(stream)) diff --git a/Carter Games/Save Manager/Code/Runtime/Saving/Handlers/WebSaveHandler.cs b/Carter Games/Save Manager/Code/Runtime/Saving/Handlers/WebSaveHandler.cs index 818871c..8b64caa 100644 --- a/Carter Games/Save Manager/Code/Runtime/Saving/Handlers/WebSaveHandler.cs +++ b/Carter Games/Save Manager/Code/Runtime/Saving/Handlers/WebSaveHandler.cs @@ -99,7 +99,7 @@ public SerializableDictionary> Lo { SerializableDictionary> jsonData; - using (var stream = new FileStream(AssetAccessor.GetAsset().SavePath, + using (var stream = new FileStream(AssetAccessor.GetAsset().SavePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite)) { using (var reader = new StreamReader(stream))