Skip to content

Commit 427eef9

Browse files
authored
Merge pull request #49 from AndanteTribe/feature/shared-unity-only
Feature/shared unity only
2 parents 722dc2a + 613082f commit 427eef9

File tree

14 files changed

+41
-69
lines changed

14 files changed

+41
-69
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Unity’s built-in `UnityEngine.PlayerPrefs` API is known for several critical i
2323

2424
**LocalPrefs** addresses these problems and offers a high-performance implementation.
2525

26-
1. When using `LocalPrefs.Shared`, the default save path is `Application.persistentDataPath` in Unity. In .NET environments, an equivalent persistent path is used.
26+
1. The save path of `LocalPrefs.Shared` (`LocalPrefs.Unity`) defaults to `Application.persistentDataPath`. On WebGL, the optimal save destination is automatically configured.
2727
2. It provides APIs that allow customization, such as defining save paths and encryption. It also offers an abstraction layer through the `ILocalPrefs` interface to enable unified save/load management.
2828
3. It supports high-performance serialization using either `System.Text.Json` or [MessagePack-CSharp](https://github.com/MessagePack-CSharp/MessagePack-CSharp).
2929
4. By integrating with native JavaScript, it supports APIs for saving/loading using Local Storage and IndexedDB, along with unified implementations based on these.
@@ -62,7 +62,7 @@ The simplest implementation uses `LocalPrefs.Shared`.
6262
The types that can be saved/loaded depend on the serializer used. As long as the serializer’s requirements are met, any type can be handled.
6363

6464
```csharp
65-
using AndanteTribe.IO;
65+
using AndanteTribe.IO.Unity;
6666

6767
var hoge = new Hoge();
6868

README_JA.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Unityの `UnityEngine.PlayerPrefs` は非常に問題の多いAPIで、以下の
2323

2424
LocalPrefsはこれらの問題を解消し、かつ高速な実装を提供します。
2525

26-
1. `LocalPrefs.Shared` の保存先はUnityの場合は `Application.persistentDataPath`、.NETの場合もそれに準じたパスが指定されます
26+
1. `LocalPrefs.Shared` `LocalPrefs.Unity`)の保存先は基本的に `Application.persistentDataPath` 、WebGLだと自動的に最適な保存先が指定されます
2727
2. 保存先や暗号化など、独自の拡張をすることを入れ込むことを可能にするAPIを提供します。また、セーブ・ロードの一括制御をする実装の抽象レイヤーとして `ILocalPrefs` インターフェイスを提供します。
2828
3. `System.Text.Json` または [MessagePack-CSharp](https://github.com/MessagePack-CSharp/MessagePack-CSharp) を利用した、高速な読み込み実装を提供します。
2929
4. JavaScriptネイティブな実装との連携により、Local storageとIndexedDBへの保存・展開を可能とするAPIの提供、およびそれらを利用した一括制御実装を提供します。
@@ -59,7 +59,7 @@ Install-Package LocalPrefs.MessagePack
5959
指定する型は依存するシリアライザーによります。シリアライザー側の要件を満たせればどの型でもセーブ・ロードが可能です。
6060

6161
```cs
62-
using AndanteTribe.IO;
62+
using AndanteTribe.IO.Unity;
6363

6464
var hoge = new Hoge();
6565

-2 KB
Binary file not shown.

bin/LocalPrefs.Core/LocalPrefs.Core.xml

Lines changed: 0 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

src/LocalPrefs.Tests/Editor/LocalPrefsCoreTest.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ public void TearDown()
4747
}
4848
}
4949

50+
#if UNITY_EDITOR || UNITY_WEBGL
51+
[Test]
52+
public void Shared_IsNotNull() => LocalPrefsTest.Shared_IsNotNul();
53+
#endif
54+
5055
[TestCaseSource(nameof(s_factories))]
5156
public Task SaveAndLoad_Int(Func<ILocalPrefs> factory)=>
5257
LocalPrefsTest.SaveAndLoad_Int(factory).AsTask();

src/LocalPrefs.Tests/Runtime/LocalPrefsTest.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ public static class LocalPrefsTest
2626
0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30
2727
};
2828

29+
#if UNITY_EDITOR || UNITY_WEBGL
30+
public static void Shared_IsNotNul() => Assert.That(Unity.LocalPrefs.Shared, Is.Not.Null);
31+
#endif
32+
2933
public static async ValueTask SaveAndLoad_Int(Func<ILocalPrefs> factory)
3034
{
3135
var prefs = factory();

src/LocalPrefs.Unity/Assets/Tests/LSPrefsTest.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ public void TearDown()
3636
LSUtils.Delete(LocalPrefsTest.TestFilePath);
3737
}
3838

39+
[Test]
40+
public void Shared_IsNotNull() => LocalPrefsTest.Shared_IsNotNul();
41+
3942
[UnityTest]
4043
public IEnumerator SaveAndLoad_Int([ValueSource(nameof(s_factories))] Func<ILocalPrefs> factory)
4144
{
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
namespace AndanteTribe.IO.Unity
2+
{
3+
/// <summary>
4+
/// Provides access to local preferences.
5+
/// </summary>
6+
public static class LocalPrefs
7+
{
8+
/// <summary>
9+
/// Shared instance of <see cref="ILocalPrefs"/>.
10+
/// </summary>
11+
public static ILocalPrefs Shared { get; internal set; }
12+
}
13+
}

0 commit comments

Comments
 (0)