Unity3D工程中的特殊文件夹及其在不同平台下的目录

请尊重原作者的工作,转载时请务必注明转载自:www.xionggf.com

目录名 作用 仅能放置于工程根目录吗 会打包进最终发布包吗 仅在编辑阶段使用吗 读取方式 打包时会原样保留原始文件格式吗
Editor 放置一些第三方或者自定义的编辑辅助工具的代码 N N Y -
Editor Default Resources 编辑器用到的一些资源,比如图片、文本文件、等等。放在这里 Y N Y 调用EditorGUIUtility.Load读取 -
Gizmos 用来在编辑阶段绘制一些辅助图标辅助线条 Y N Y 在MonoBehavior类的OnDrawGizmos方法中使用 -
Plugins Andoird 或者 iOS平台下,要给工程接一些SDK时可以把SDK依赖的库文件如 .so .jar .a文件放置从此处 N Y N - N
Resources Resources文件夹下的资源不管你用还是不用都会被打包进.apk或者.ipa N Y N Resource.Load函数: 编辑时和运行时都可以通过Resource.Load来直接读取。Resources.LoadAssetAtPath它可以读取Assets目录下的任意文件夹下的资源,它可以在编辑时或者编辑器运行时用,它但是它不能在真机上用,它的路径是 ”Assets/xx/xx.xxx” 必须是这种路径,并且要带文件的后缀名。 N
StreamingAssets 并且它是一个只读的文件夹,就是程序运行时只能读 不能写。它在各个平台下的路径是不同的 N Y N Application.streamingAssetsPath 是访问这些目录下的资源路径的方法。它会根据当前的平台选择对应的路径。 Y

Application类中定义的若干路径在不同平台下的具体值如下表:

变量Application.dataPath

  1. Windows: –
  2. Android: /data/app/xxx.xxx.xxx.apk
  3. iOS: Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/xxx.app/Data

变量Application.streamingAssetsPath

  1. Windows: –
  2. Android: jar:file:///data/app/xxx.xxx.xxx.apk/!/assets
  3. iOS: Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/xxx.app/Data/Raw

变量Application.persistentDataPath

  1. Windows: –
  2. Android: /data/data/xxx.xxx.xxx/files
  3. iOS: Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/Documents

变量Application.temporaryCachePath

  1. Windows: –
  2. Android: /data/data/xxx.xxx.xxx/cache
  3. iOS: Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/Library/Caches