This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ShrinkTutorial
|
||||
{
|
||||
[Serializable]
|
||||
public sealed class ShrinkTutorialProgress
|
||||
{
|
||||
public List<string> completedTutorials = new();
|
||||
public List<string> skippedTutorials = new();
|
||||
}
|
||||
|
||||
public interface IShrinkTutorialStorage
|
||||
{
|
||||
ShrinkTutorialProgress Load();
|
||||
void Save(ShrinkTutorialProgress progress);
|
||||
void Reset();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 67a3fb9a0dd678c4eb81a707d0d95697
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,41 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace ShrinkTutorial
|
||||
{
|
||||
public sealed class PlayerPrefsShrinkTutorialStorage : IShrinkTutorialStorage
|
||||
{
|
||||
private readonly string _storageKey;
|
||||
|
||||
public PlayerPrefsShrinkTutorialStorage(string storageKey)
|
||||
{
|
||||
_storageKey = string.IsNullOrWhiteSpace(storageKey)
|
||||
? "ShrinkTutorial.Progress"
|
||||
: storageKey;
|
||||
}
|
||||
|
||||
public ShrinkTutorialProgress Load()
|
||||
{
|
||||
if (!PlayerPrefs.HasKey(_storageKey))
|
||||
return new ShrinkTutorialProgress();
|
||||
|
||||
var json = PlayerPrefs.GetString(_storageKey, string.Empty);
|
||||
if (string.IsNullOrWhiteSpace(json))
|
||||
return new ShrinkTutorialProgress();
|
||||
|
||||
return JsonUtility.FromJson<ShrinkTutorialProgress>(json) ?? new ShrinkTutorialProgress();
|
||||
}
|
||||
|
||||
public void Save(ShrinkTutorialProgress progress)
|
||||
{
|
||||
var json = JsonUtility.ToJson(progress ?? new ShrinkTutorialProgress());
|
||||
PlayerPrefs.SetString(_storageKey, json);
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
PlayerPrefs.DeleteKey(_storageKey);
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4cfcca11fd52a15428f5db55524c7380
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user