summaryrefslogtreecommitdiff
path: root/Assets/Scripts/PathHelper.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Assets/Scripts/PathHelper.cs')
-rw-r--r--Assets/Scripts/PathHelper.cs41
1 files changed, 41 insertions, 0 deletions
diff --git a/Assets/Scripts/PathHelper.cs b/Assets/Scripts/PathHelper.cs
new file mode 100644
index 0000000..7c23dd6
--- /dev/null
+++ b/Assets/Scripts/PathHelper.cs
@@ -0,0 +1,41 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class PathHelper{
+ // 用于bundle读取的streaming路径
+ // 不需要加file://协议
+ public static string GetStreamingFullFilePath(string filePath)
+ {
+#if UNITY_ANDROID
+ return Application.dataPath + "!assets/" + filePath;
+#else
+ return Application.streamingAssetsPath + "/" + filePath;
+#endif
+ }
+
+ // 用于www读取的streaming路径
+ // 需要加file协议
+ public static string GetStreamingWWWFullFilePath(string filePath)
+ {
+#if UNITY_ANDROID
+ return Application.streamingAssetsPath + "/" + filePath;
+#else
+ return "file://" + Application.streamingAssetsPath + "/" + filePath;
+#endif
+ }
+
+ public static string GetPersistentFullFilePath(string filePath)
+ {
+ return Application.persistentDataPath + "/" + filePath;
+ }
+
+#if UNITY_IOS
+// 将文件从自动上传iCloud中排除
+public static void ExcludeFileFromiCloud(string filePath)
+{
+ string full = GetPersistentFullFilePath(filePath);
+ UnityEngine.iOS.Device.SetNoBackupFlag(full);
+}
+#endif
+}