64 lines
1.6 KiB
C#
64 lines
1.6 KiB
C#
using System;
|
|
using System.Globalization;
|
|
using UnityEngine;
|
|
|
|
namespace Superlazy
|
|
{
|
|
internal class SLOption
|
|
{
|
|
internal static void Init()
|
|
{
|
|
CultureInfo.CurrentCulture = CultureInfo.InvariantCulture;
|
|
if (PlayerPrefs.HasKey("AppID") == false)
|
|
{
|
|
PlayerPrefs.SetString("AppID", Guid.NewGuid().ToString());
|
|
PlayerPrefs.Save();
|
|
}
|
|
}
|
|
|
|
public static void InitOption(string key, SLEntity option)
|
|
{
|
|
if (PlayerPrefs.HasKey(OptionString(key)))
|
|
{
|
|
SetOption(key, PlayerPrefs.GetString(OptionString(key)));
|
|
}
|
|
else
|
|
{
|
|
SetOption(key, option);
|
|
}
|
|
}
|
|
|
|
public static void SetOption(string key, SLEntity option)
|
|
{
|
|
if (option.ToString() == string.Empty)
|
|
{
|
|
option = false;
|
|
}
|
|
SLGame.Session["Options"][key] = option;
|
|
PlayerPrefs.SetString(OptionString(key), option);
|
|
}
|
|
|
|
public static SLEntity GetOption(string key)
|
|
{
|
|
if (SLGame.Session["Options"][key])
|
|
{
|
|
return SLGame.Session["Options"][key];
|
|
}
|
|
else
|
|
{
|
|
SLLog.Error($"Option not found: {key}");
|
|
return SLEntity.Empty;
|
|
}
|
|
}
|
|
|
|
private static string OptionString(string key)
|
|
{
|
|
return "Option_" + key;
|
|
}
|
|
|
|
internal static void Save()
|
|
{
|
|
PlayerPrefs.Save();
|
|
}
|
|
}
|
|
} |