Beispiel #1
0
    public bool Load()
    {
        Debug.Log("Loading prefs...");

        PlayBoundsPrefs fileP  = FileLoad();
        PlayBoundsPrefs steamP = null; // SteamLoad();

        bool res = false;

        bool            skipSteam = false;
        PlayBoundsPrefs p         = new PlayBoundsPrefs();

        if (fileP != null && steamP != null)
        {
            if (fileP.lastEditTime >= steamP.lastEditTime)
            {
                p = fileP;
            }
            else
            {
                p         = steamP;
                skipSteam = true;
            }

            res = true;
        }
        else if (fileP == null && steamP != null)
        {
            p         = steamP;
            skipSteam = true;
            res       = true;
        }
        else if (fileP != null && steamP == null)
        {
            p   = fileP;
            res = true;
        }

        prefs = p;
        //Save(skipSteam);

        return(res);
    }
Beispiel #2
0
    public bool Save(bool skipSteam = false, PlayBoundsPrefs overrideP = null)
    {
        try
        {
            PlayBoundsPrefs p;

            if (overrideP != null)
            {
                p = overrideP;
            }
            else
            {
                p = prefs;
            }

            p.lastEditTime = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;

            string text  = JsonUtility.ToJson(prefs, true);
            string fullP = _filePath + _fileName;

            Debug.Log("Writing Local Prefs!");
            File.WriteAllText(fullP, text);

            try
            {
                if (!skipSteam)
                {
                    SteamSave();
                }
            }
            catch (System.Exception e)
            {
                Debug.LogError("Error when saving to Steam.");
            }

            return(File.Exists(fullP));
        }
        catch (System.Exception e)
        {
            return(false);
        }
    }