代码
using System.Text;
using UnityEngine;
public class StreamingAssetsPath
{
private static StringBuilder m_Path = new StringBuilder(256);
public static string AppContentPath()
{
m_Path.Length = 0;
string path = string.Empty;
switch (Application.platform)
{
case RuntimePlatform.Android:
path = m_Path.AppendFormat("jar:file://{0}!/assets/", Application.dataPath).ToString();
break;
case RuntimePlatform.IPhonePlayer:
path = m_Path.AppendFormat("{0}/Raw/", Application.dataPath).ToString();
break;
case RuntimePlatform.WindowsPlayer:
path = m_Path.AppendFormat("{0}/StreamingAssets/", Application.dataPath).ToString();
break;
default:
path = m_Path.AppendFormat("{0}/StreamingAssets/", Application.dataPath).ToString();
break;
}
return path;
}
public static string AppContentPathURL()
{
m_Path.Length = 0;
string path = string.Empty;
switch (Application.platform)
{
case RuntimePlatform.Android:
path = m_Path.AppendFormat("jar:file://{0}!/assets/", Application.dataPath).ToString();
break;
case RuntimePlatform.IPhonePlayer:
path = m_Path.AppendFormat("file://{0}/Raw/", Application.dataPath).ToString();
break;
case RuntimePlatform.WindowsPlayer:
path = m_Path.AppendFormat("file://{0}/StreamingAssets/", Application.dataPath).ToString();
break;
default:
path = m_Path.AppendFormat("file://{0}/StreamingAssets/", Application.dataPath).ToString();
break;
}
return path;
}
}
参考
参考原文:https://blog.csdn.net/yuxikuo_1/article/details/52812141