public static SaveData LoadFromDisk()
        {
            if (!IsSaveDataAvailableAtDisk())
            {
                return(RecreateDataOnDisk());
            }

            try {
                SaveData saveData = Load();
                if (!saveData.Validate())
                {
                    saveData.Save();

                    // reload and construct again from disk
                    return(Load());
                }
                else
                {
                    return(saveData);
                }
            } catch (Exception e) {
                Debug.LogError("Failed to deserialize AssetBundleGraph settings. Error:" + e + " File:" + SaveDataPath);
            }

            return(new SaveData());
        }
Пример #2
0
        private static void LoadFromDisk()
        {
            // First, try loading from asset.
            try {
                var path = SaveDataAssetPath;

                if (File.Exists(path))
                {
                    SaveData data = AssetDatabase.LoadAssetAtPath <SaveData>(path);

                    if (data != null)
                    {
                        if (data.m_version > ABG_FILE_VERSION)
                        {
                            LogUtility.Logger.LogFormat(LogType.Warning, "AssetBundleGraph Savedata on disk is too new(our version:{0} config version:{1}). Saving project may cause data loss.",
                                                        ABG_FILE_VERSION, data.m_version);
                        }

                        data.Validate();
                        s_saveData = data;
                        return;
                    }
                }
            } catch (Exception e) {
                LogUtility.Logger.LogWarning(LogUtility.kTag, e);
            }

            // If there is no asset found, look for json.
            try {
                if (File.Exists(SaveDataJsonPath))
                {
                    LoadJsonData();
                    return;
                }
            } catch (Exception e) {
                LogUtility.Logger.LogError(LogUtility.kTag, "Failed to deserialize AssetBundleGraph settings. Error:" + e + " File:" + SaveDataJsonPath);
            }

            CreateNewSaveData();
        }