using UnityEngine;
using System.Collections;
using System.Text;
public class Path : MonoBehaviour {
private static StringBuilder m_Path = new StringBuilder(256);
void Awake()
{
Debug.Log( "path = " + AppContentPath() );
Debug.Log( "path url = " + AppContentPathURL() );
}
void OnGUI()
{
GUI.Label( new Rect(10,10,400,30), AppContentPath() );
GUI.Label( new Rect(10,50,400,30), AppContentPathURL() );
}
public 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 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;
}
}
Unity中的StreamingAssets
最新推荐文章于 2023-12-09 12:14:33 发布