Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
io.gs2.unity.sdk.uikit / Gs2Account / Repository / PlayerPrefsAccountRepository.cs
Size: Mime:
using Gs2.Gs2Account.Model;
using Gs2.Unity.Gs2Account.Model;
using Gs2.Util.LitJson;
using Gs2.Util.WebSocketSharp;
using UnityEngine;

namespace Gs2.Unity.UiKit.Gs2Account
{
    [AddComponentMenu("GS2 UIKit/Account/AccountRepository/PlayerPrefsAccountRepository")]
    public class PlayerPrefsAccountRepository : AbstractAccountRepository
    {
        public string playerPrefsKey = "Gs2.Account";
        
        public override EzAccount Load()
        {
            var account = PlayerPrefs.GetString(playerPrefsKey);
            if (account.IsNullOrEmpty())
            {
                return null;
            }
            return EzAccount.FromModel(Account.FromJson(JsonMapper.ToObject(account)));
        }

        public override void Save(EzAccount account)
        {
            PlayerPrefs.SetString(playerPrefsKey, account.ToModel().ToJson().ToJson());
        }

        public override void Delete()
        {
            PlayerPrefs.DeleteKey(playerPrefsKey);
        }
    }
}