Просмотр исходного кода

1.读取ios StreamingAssets中的文件需要加file:// 安卓却不需要加
2.用AssetBundle.LoadFromFile读取StreamingAssets的ab包都不需要加file://

tanghai 7 лет назад
Родитель
Сommit
fd6374b657

+ 16 - 0
Unity/Assets/Scripts/Helper/PathHelper.cs

@@ -31,5 +31,21 @@ namespace ETModel
                 return Application.streamingAssetsPath;
             }
         }
+
+        /// <summary>
+        /// 应用程序内部资源路径存放路径(www/webrequest专用)
+        /// </summary>
+        public static string AppResPath4Web
+        {
+            get
+            {
+#if UNITY_IOS
+                return $"file://{Application.streamingAssetsPath}";
+#else
+                return Application.streamingAssetsPath;
+#endif
+
+            }
+        }
     }
 }

+ 1 - 1
Unity/Assets/Scripts/Module/AssetsBundle/BundleDownloaderComponent.cs

@@ -56,7 +56,7 @@ namespace ETModel
 			}
 			else
 			{
-				versionPath = Path.Combine(PathHelper.AppResPath, "Version.txt");
+				versionPath = Path.Combine(PathHelper.AppResPath4Web, "Version.txt");
 				using (UnityWebRequestAsync request = ComponentFactory.Create<UnityWebRequestAsync>())
 				{
 					await request.DownloadAsync(versionPath);