Skip to content

Commit bd7aeeb

Browse files
fix: null reference error fix
1 parent f8657cd commit bd7aeeb

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

sample/Assets/Editor/MacBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ static void Build()
1414
{
1515
BuildPlayer(DefaultBuildPath, BuildOptions.None);
1616
}
17-
[MenuItem("Build/MacOS/Build for AltTester")]
17+
1818
static void BuildForAltTester()
1919
{
2020
BuildPlayer(DefaultBuildPath, BuildOptions.Development | BuildOptions.IncludeTestAssemblies | BuildOptions.AutoRunPlayer, true);

sample/Assets/Scripts/Passport/ClearStorageAndCache/ClearStorageAndCacheScript.cs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,24 @@ public class ClearStorageAndCacheScript : MonoBehaviour
99

1010
public void ClearStorageAndCache()
1111
{
12-
#if (UNITY_IPHONE && !UNITY_EDITOR) || (UNITY_ANDROID && !UNITY_EDITOR)
13-
Passport.ClearStorage();
14-
Passport.ClearCache(true);
15-
ShowOutput("Cleared storage and cache");
12+
if (Passport.Instance == null)
13+
{
14+
ShowOutput("Passport instance is null. Initialize Passport first.");
15+
return;
16+
}
17+
18+
#if UNITY_ANDROID && !UNITY_EDITOR
19+
ShowOutput("Clearing storage and cache...");
20+
Passport.Instance.ClearStorage();
21+
Passport.Instance.ClearCache(true);
22+
ShowOutput("Storage and cache cleared (on Android).");
23+
#elif UNITY_IPHONE && !UNITY_EDITOR
24+
ShowOutput("Clearing storage and cache...");
25+
Passport.Instance.ClearStorage();
26+
Passport.Instance.ClearCache(true);
27+
ShowOutput("Storage and cache cleared (on iOS).");
1628
#else
17-
ShowOutput("Support on Android and iOS devices only");
29+
ShowOutput("ClearStorageAndCache is only available on Android and iOS devices.");
1830
#endif
1931
}
2032

0 commit comments

Comments
 (0)