zoukankan      html  css  js  c++  java
  • Unity发布各平台路径

    #if UNITY_EDITOR
    string filepath = Application.dataPath + "/StreamingAssets";
    
    #elif UNITY_IPHONE
    string filepath = Application.dataPath +"/Raw";
    
    #elif UNITY_ANDROID
    string filepath =Application.streamingAssetsPath;
    
    #endif

    安卓获取文件时 需要通过WWW进行下载。其他平台通过IO 读取就行。

    另外一种方法使用

    Application.persistentDataPath 路径

    不同的是Application.streamingAssetsPath 可以在项目中新建"StreamingAssets" 文件夹后预存自己 需要访问的文件。。

    Android jar:file:// + Application.dataPath + "/StreamingAssets";

    IOS :file:// + Application.dataPath +"/Raw";

     
    public static string initAssetPath() {
    #if UNITY_EDITOR || UNITY_STANDALONE_WIN
            return "file://" + Application.dataPath + "/StreamingAssets/";
    #elif UNITY_ANDROID
            return "jar:file://" + Application.dataPath + "!/assets/";
    #elif UNITY_IPHONE
            return Application.dataPath + "/Raw/";
    #else
            return "";
    #endif
        }
    "StreamingAssets" 文件夹  
    读取下载创建都使用:
    
    string  m_filepath = Application.persistentDataPath;
    
    "StreamingAssets" 文件夹  
    读取下载都使用:
    string  m_filepath ="jar:file://" + Application.persistentDataPath;
  • 相关阅读:
    js获取数组中的值显示[object HTMLInputElement]
    IntelliJ Idea 常用快捷键
    MySQL查询本周、上周、本月、上个月份数据的sql代码
    表的基本
    字符串类型
    备份数据库
    增加标 和增加其内容
    数据库的基本
    jq做的简单的变色表格
    jq做的简单的轮播
  • 原文地址:https://www.cnblogs.com/123ing/p/3705044.html
Copyright © 2011-2022 走看看