zoukankan      html  css  js  c++  java
  • 【Unity 系统知识】 各种路径

    一.Assets下的Resources(Unity系统文件夹)

      :路径 Application.dataPath/Resources

    可以使用Resources.Load("文件名字,注:不包括文件后缀名");把文件夹中的对象加载出来。

    GameObject go = Resources.Load("xxxx") as GameObject

    该文件夹在编辑器下可以增删操作,打包之后不可以。

     

    二.Assets文件夹  

      :路径 Application.dataPath

    该文件夹在编辑器下可以增删操作,打包之后不可以。

     

    三.Assets下的StreamingAssets(Unity系统文件夹)

      :路径 Application.dataPath/StreamingAssets

      :路径 Application.streamingAssetsPath

      这个属性用于返回流数据的缓存目录,返回路径为相对路径,适合设置一些外部数据文件的路径。

    这个文件夹中的资源在打包时会原封不动的打包进去,不会压缩,一般放置一些资源数据。

    该文件夹在编辑器下可以增删操作,打包之后不可以。

     

    四. 持久化数据存储目录 (推荐使用)

      :路径 Application.persistentDataPath

      这个路径可读、可写,但是只能在程序运行时才能读写操作,不能提前将数据放入这个路径。

    在IOS上是应用程序的沙盒,可以被iCloud自动备份,可以通过同步推送一类的助手直接取出文件;

    在Android上的位置是根据Project Setting里设置的Write Access路径,可以设置是程序沙盒还是sdcard,

    注意:如果在Android设置保存在沙盒中,那么就必须root以后才能用电脑取出文件,因此建议写入sdcard里。

    一般情况下,建议将获得的文件保存在这个路径下,例如可以从StreamingAsset中读取的二进制文件或者

    从AssetBundle读取的文件写入PersistentDatapath。

     

    以上各路径中的资源加载方式都可以用WWW类加载,但要注意各个平台路径需要加的访问名称,例如Android平台的路径前要加"jar:file://",其他平台使用"file://"。以下是各路径在各平台中的具体位置信息

    Andorid平台
      Application.dataPath :  /data/app/xxx.xxx.xxx.apk
      Application.streamingAssetsPath :  jar:file:///data/app/xxx.xxx.xxx.apk/!/assets
      Application.persistentDataPath :  /data/data/xxx.xxx.xxx/files
      Application.temporaryCachePath :  /data/data/xxx.xxx.xxx/cache
    IOS平台
      Application.dataPath :                    Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/xxx.app/Data
      Application.streamingAssetsPath : Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/xxx.app/Data/Raw
      Application.persistentDataPath :    Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/Documents
      Application.temporaryCachePath : Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/Library/Caches
     

     



  • 相关阅读:
    python自学第13天 hashlib,re模块
    python自学第12天 模块
    python自学第12天 模块定义,导入,内置模块
    python自学第11天-单线程并发、迭代器,序列化,获取路径
    python自学第10天,生成器
    python自学第9天,装饰器
    python自学第8天,变量,递归
    python自学第7天,函数,参数
    彻底搞懂Session与Cookie的异同!
    你真的搞懂了Java中的<<、>>、>>>运算符嘛?
  • 原文地址:https://www.cnblogs.com/nanwei/p/9558317.html
Copyright © 2011-2022 走看看