您好,欢迎来到花图问答。
搜索
您的当前位置:首页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);
}

本文如未解决您的问题请添加抖音号:51dongshi(抖音搜索懂视),直接咨询即可。

热门图文

Copyright © 2019-2025 huatuowenda.com 版权所有 湘ICP备2023022495号-1

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

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