Skip to content
This repository was archived by the owner on Sep 7, 2022. It is now read-only.

Commit 36e7cb6

Browse files
committed
fix android issue
1 parent 59178c3 commit 36e7cb6

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

com.unity.uiwidgets/Runtime/engine/AndroidPlatformUtil.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,21 @@ public static class UIWidgetsAndroidConfiguration{
1717

1818
internal delegate string UnpackFileCallback(string file);
1919

20+
internal static bool FileExists(string file)
21+
{
22+
var path = "jar:file://" + Application.dataPath + "!/assets/" + file;
23+
using (var unpackerWWW = UnityWebRequest.Get(path)) {
24+
unpackerWWW.SendWebRequest();
25+
while (!unpackerWWW.isDone) {
26+
} // This will block in the webplayer.
27+
28+
if (unpackerWWW.isNetworkError || unpackerWWW.isHttpError) {
29+
return false;
30+
}
31+
}
32+
return true;
33+
}
34+
2035
[MonoPInvokeCallback(typeof(UnpackFileCallback))]
2136
internal static string unpackFile(string file) {
2237
var dir = Application.temporaryCachePath + "/";

com.unity.uiwidgets/Runtime/engine/UIWidgetsPanel.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,11 @@ public object fontsToObject() {
7676
if (setting.Value.fonts[j].asset.Length > 0) {
7777
var assetPath = setting.Value.fonts[j].asset;
7878
var assetAbsolutePath = Path.Combine(Application.streamingAssetsPath, assetPath);
79+
#if !UNITY_EDITOR && UNITY_ANDROID
80+
if (!AndroidPlatformUtil.FileExists(assetPath)) {
81+
#else
7982
if (!File.Exists(assetAbsolutePath)) {
83+
#endif
8084
Debug.LogError($"The font asset (family: \"{setting.Key}\", path: \"{assetPath}\") is not found");
8185
}
8286
else {

0 commit comments

Comments
 (0)