Exemple #1
0
    /*
     * public static List<string> GetExtraFiles(string metaFileName)
     * {
     *      var str = GetSaveFileContents(metaFileName);
     * }
     */
    public static SaveFileData OpenFile(string path)
    {
        var str = GetSaveFileContents(path);

        str = VersionManager.CheckAndUpgradeVersion(str);

        var saveFileData = new SaveFileData();

        var result = new ParsedJsonLine();

        result = JsonGetValueFromLine(str, result.endindex);
        saveFileData.meta.version = Convert.ToInt32(result.value);

        result = JsonGetValueFromLine(str, result.endindex);
        saveFileData.meta.guid = new Guid(result.value);

        result = JsonGetValueFromLine(str, result.endindex);
        saveFileData.meta.title = result.value;

        result = JsonGetValueFromLine(str, result.endindex);
        saveFileData.meta.description = result.value;

        result = JsonGetValueFromLine(str, result.endindex);
        saveFileData.meta.length = Convert.ToSingle(result.value);

        saveFileData.points = new List <InteractionpointSerialize>();

        foreach (var obj in ParseInteractionPoints(str, result.endindex))
        {
            saveFileData.points.Add(JsonUtility.FromJson <InteractionpointSerialize>(obj));
        }

        if (VersionManager.isUpdated)
        {
            try
            {
                using (var file = File.CreateText(path))
                {
                    file.Write(str);
                }
            }
            catch (Exception e)
            {
                Debug.Log(e.ToString());
            }
        }

        return(saveFileData);
    }