Unity中的StreamingAssets

来源:互联网 发布:乐高淘宝散件怎么来的 编辑:程序博客网 时间:2024/06/05 19:19
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;    }}

0 0