您好,欢迎来到伴沃教育。
搜索
您的当前位置:首页unity读取streamingassets路径下文件

unity读取streamingassets路径下文件

来源:伴沃教育

It’s always best to use Application.streamingAssetsPath
to get the location of the StreamingAssets folder, as it will always point to the correct location on the platform where the application is running.

On a desktop computer (Mac OS or Windows) the location of the files can be obtained with the following code:
path = Application.dataPath + "/StreamingAssets";
On iOS, use:
path = Application.dataPath + "/Raw";
On Android, use:
path = "jar:file://" + Application.dataPath + "!/assets/";

On Android, the files are contained within a compressed .jar file (which is essentially the same format as standard zip-compressed files). This means that if you do not use Unity’s class to retrieve the file, you need to use additional software to see inside the .jar archive and obtain the file.

  public string filePath =  "MyFile");
  public string result = "";
  IEnumerator Example() {
    if (filePath.Contains("://")) {
          = new 
        yield return 
        result = 
    } else
        result = System.IO.File.ReadAllText(filePath);
}

Copyright © 2019- bangwoyixia.com 版权所有 湘ICP备2023022004号-2

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务