Unity官方文档:

Special folder names

You can usually choose any name you like for the folders you create to organise your Unity project. However, there are a number of folder names that Unity interprets as an instruction that the folder’s contents should be treated in a special way. For example, you must place Editor scripts in a folder called Editor for them to work correctly.

This page contains the full list of special folder names used by Unity.

Assets

The Assets folder is the main folder that contains the Assets used by a Unity project. The contents of the Project window in the Editor correspond directly to the contents of the Assets folder. Most API functions assume that everything is located in the Assets folder, and so don’t require it to be mentioned explicitly. However, some functions do need to have the Assets folder included as part of a pathname (for example, certain functions in the AssetDatabase class).

Editor

Scripts placed in a folder called Editor are treated as Editor scripts rather than runtime scripts. These scripts add functionality to the Editor during development, and are not available in builds at runtime.

You can have multiple Editor folders placed anywhere inside the Assets folder. Place your Editor scripts inside an Editor folder or a subfolder within it.

The exact location of an Editor folder affects the time at which its scripts will be compiled relative to other scripts (see documentation on Special Folders and Script Compilation Order for a full description of this). Use the EditorGUIUtility.Load function in Editor scripts to load Assets from a Resources folder within an Editor folder. These Assets can only be loaded via Editor scripts, and are stripped from builds.

Note: Unity does not allow components derived from MonoBehaviour to be assigned to GameObjects if the scripts are in the Editor folder.

Editor Default Resources

Editor scripts can make use of Asset files loaded on-demand using the EditorGUIUtility.Load function. This function looks for the Asset files in a folder called Editor Default Resources.

You can only have one Editor Default Resources folder and it must be placed in the root of the Project; directly within the Assets folder. Place the needed Asset files in this Editor Default Resources folder or a subfolder within it. Always include the subfolder path in the path passed to the EditorGUIUtility.Load function if your Asset files are in subfolders.

Gizmos

Gizmos allow you to add graphics to the Scene View to help visualise design details that are otherwise invisible. The Gizmos.DrawIcon function places an icon in the Scene to act as a marker for a special object or position. You must place the image file used to draw this icon in a folder called Gizmos in order for it to be located by the DrawIcon function.

You can only have one Gizmos folder and it must be placed in the root of the Project; directly within the Assets folder. Place the needed Asset files in this Gizmos folder or a subfolder within it. Always include the subfolder path in the path passed to the Gizmos.DrawIcon function if your Asset files are in subfolders.

Plug-ins

You can add plug-ins to your Project to extend Unity’s features. Plug-ins are native DLLs that are typically written in C/C++. They can access third-party code libraries, system calls and other Unity built-in functionality. Always place plug-ins in a folder called Plugins for them to be detected by Unity.

You can only have one Plugins folder and it must be placed in the root of the Project; directly within the Assets folder.

See Special folders and script compilation order for more information on how this folder affects script compilation, and Plugin Inspector for more information on managing plug-ins for different target platforms.

Resources

You can load Assets on-demand from a script instead of creating instances of Assets in a Scene for use in gameplay. You do this by placing the Assets in a folder called Resources. Load these Assets by using the Resources.Load function.

You can have multiple Resources folders placed anywhere inside the Assets folder. Place the needed Asset files in a Resources folder or a subfolder within it. Always include the subfolder path in the path passed to the Resources.Load function if your Asset files are in subfolders.

Note that if the Resources folder is an Editor subfolder, the Assets in it are loadable from Editor scripts but are stripped from builds.

Standard Assets

When you import a Standard Asset package (menu: Assets > Import Package) the Assets are placed in a folder called Standard Assets. As well as containing the Assets, these folders also have an effect on script compilation order; see the page on Special Folders and Script Compilation Order for further details.

You can only have one Standard Assets folder and it must be placed in the root of the Project; directly within the Assets folder. Place the needed Assets files in this Standard Assets folder or a subfolder within it.

StreamingAssets

You may want the Asset to be available as a separate file in its original format although it is more common to directly incorporate Assets into a build. For example, you need to access a video file from the filesystem rather than use it as a MovieTexture to play that video on iOS. Place a file in a folder called StreamingAssets, so it is copied unchanged to the target machine, where it is then available from a specific folder. See the page about Streaming Assets for further details.

You can only have one StreamingAssets folder and it must be placed in the root of the Project; directly within the Assets folder. Place the needed Assets files in this StreamingAssets folder or a subfolder within it. Always include the subfolder path in the path used to reference the streaming asset if your Asset files are in subfolders.

Most assets in Unity are combined into the project when it is built. However, it is sometimes useful to place files into the normal filesystem on the target machine to make them accessible via a pathname. An example of this is the deployment of a movie file on iOS devices; the original movie file must be available from a location in the filesystem to be played by the PlayMovie function.

Any files placed in a folder called StreamingAssets (case-sensitive) in a Unity project will be copied verbatim to a particular folder on the target machine. You can retrieve the folder using the Application.streamingAssetsPath property. 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.

The location of this folder varies per platform. Please note that these are case-sensitive:

  • 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 WWW class to retrieve the file, you need to use additional software to see inside the .jar archive and obtain the file.

Note: .dll files located in the StreamingAssets folder don’t participate in the compilation.

Hidden Assets

During the import process, Unity completely ignores the following files and folders in the Assets folder (or a sub-folder within it):

  • Hidden folders.
  • Files and folders which start with ‘.’.
  • Files and folders which end with ‘~’.
  • Files and folders named cvs.
  • Files with the extension .tmp.

This is used to prevent importing special and temporary files created by the operating system or other applications.

雨松momo:

原文链接:http://www.xuanyusong.com/archives/3229

这里列举出手游开发中用到了所有特殊文件夹。

1.Editor

Editor文件夹可以在根目录下,也可以在子目录里,只要名子叫Editor就可以。比如目录:/xxx/xxx/Editor  和 /Editor 是一样的,无论多少个叫Editor的文件夹都可以。Editor下面放的所有资源文件或者脚本文件都不会被打进发布包中,并且脚本也只能在编辑时使用。一般呢会把一些工具类的脚本放在这里,或者是一些编辑时用的DLL。 比如我们现在要做类似技能编辑器,那么编辑器的代码放在这里是再好不过了,因为实际运行时我们只需要编辑器生成的文件,而不需要编辑器的核心代码。

2.Editor Default Resources

Editor Default Resources注意中间是有空格的,它必须放在Project视图的根目录下,如果你想放在/xxx/xxx/Editor Default Resources 这样是不行的。你可以把编辑器用到的一些资源放在这里,比如图片、文本文件、等等。它和Editor文件夹一样都不会被打到最终发布包里,仅仅用于开发时使用。你可以直接通过EditorGUIUtility.Load去读取该文件夹下的资源。

1
2

TextAsset text = EditorGUIUtility.Load("test.txt")as TextAsset;
Debug.Log(text.text);

3.Gizmos

我觉得这个文件夹其实没什么用处,如下代码所示它可以在Scene视图里给某个坐标绘制一个icon。它的好处是可以传一个Vecotor3 作为图片显示的位置。 参数2就是图片的名子,当然这个图片必须放在Gizmos文件夹下面。

1
2
3

    void OnDrawGizmos() {
        Gizmos.DrawIcon(transform.position, "0.png", true);
    }

如果只想挂在某个游戏对象身上,那么在Inspecotr里面就可以直接设置。。


这里还是要说说OnDrawGizmos()方法,只要脚本继承了MonoBehaviour后,并且在编辑模式下就会每一帧都执行它。发布的游戏肯定就不会执行了,它只能用于在scene视图中绘制一些小物件。比如要做摄像机轨迹,那么肯定是要在Scene视图中做一个预览的线,那么用Gizmos.DrawLine 和Gizmos.DrawFrustum就再好不过了。

4.Plugins

如果做手机游戏开发一般 andoird 或者 ios 要接一些sdk 可以把sdk依赖的库文件 放在这里,比如 .so .jar .a 文件。这样打完包以后就会自动把这些文件打在你的包中。

5.Resources

可以在根目录下,也可以在子目录里,只要名子叫Resources就可以。比如目录:/xxx/xxx/Resources  和 /Resources 是一样的,无论多少个叫Resources的文件夹都可以。Resources文件夹下的资源不管你用还是不用都会被打包进.apk或者.ipa

Resource.Load :编辑时和运行时都可以通过Resource.Load来直接读取。

Resources.LoadAssetAtPath() :它可以读取Assets目录下的任意文件夹下的资源,它可以在编辑时或者编辑器运行时用,它但是它不能在真机上用,它的路径是”Assets/xx/xx.xxx” 必须是这种路径,并且要带文件的后缀名。

AssetDatabase.LoadAssetAtPath():它可以读取Assets目录下的任意文件夹下的资源,它只能在编辑时用。它的路径是”Assets/xx/xx.xxx” 必须是这种路径,并且要带文件的后缀名。

我觉得在电脑上开发的时候尽量来用Resource.Load() 或者 Resources.LoadAssetAtPath() ,假如手机上选择一部分资源要打assetbundle,一部分资源Resource.Load().那么在做.apk或者.ipa的时候 现在都是用脚本来自动化打包,在打包之前 可以用AssetDatabase.MoveAsset()把已经打包成assetbundle的原始文件从Resources文件夹下移动出去在打包,这样打出来的运行包就不会包行多余的文件了。打完包以后再把移动出去的文件夹移动回来。

6. StreamingAssets

这个文件夹下的资源也会全都打包在.apk或者.ipa 它和Resources的区别是,Resources会压缩文件,但是它不会压缩原封不动的打包进去。并且它是一个只读的文件夹,就是程序运行时只能读 不能写。它在各个平台下的路径是不同的,不过你可以用Application.streamingAssetsPath 它会根据当前的平台选择对应的路径。

有些游戏为了让所有的资源全部使用assetbundle,会把一些初始的assetbundle放在StreamingAssets目录下,运行程序的时候在把这些assetbundle拷贝在Application.persistentDataPath目录下,如果这些assetbundle有更新的话,那么下载到新的assetbundle在把Application.persistentDataPath目录下原有的覆盖掉。

因为Application.persistentDataPath目录是应用程序的沙盒目录,所以打包之前是没有这个目录的,直到应用程序在手机上安装完毕才有这个目录。

StreamingAssets目录下的资源都是不压缩的,所以它比较大会占空间,比如你的应用装在手机上会占用100M的容量,那么你又在StreamingAssets放了一个100M的assetbundle,那么此时在装在手机上就会在200M的容量。

今天就到这里了,如果有问题欢迎大家与@雨松MOMO一起讨论。嘿嘿。

Unity 中的特殊文件夹相关推荐

  1. unity中监听文件夹并且创建文件夹后做资源更新

    unity中监听文件夹并且创建文件夹后做资源更新 有时候我们在设计的时候,可能对项目的文件内容进行监听,也可能需要在监听某个文件夹的操作,并且做出相对应的处理,例如项目资源的大小监听等,以下就提供两种 ...

  2. Unity资产,特殊文件夹以及重要路径

    本文将介绍Unity中的资产,Unity中的特殊文件夹,Unity的一些路径对应各个平台上的具体路径. 第一部分就是介绍资产Assets--哪些是Assets,Assets类型具体有哪些,如何在编辑器 ...

  3. Unity打开电脑本地文件夹选择图片替换

    Unity打开电脑本地文件夹选择图片替换 创建工程添加对应的UI如图所示 创建ChangeImage脚本来监听按钮事件 创建OpenFileName脚本 将代码挂在到窗口,点击运行 创建工程添加对应的 ...

  4. unity快速进入Project窗口文件夹

    因为 项目文件结构日渐复杂,unity的Project窗口操作又不是很人性化,所以我需要一个快速进入Project窗口中 文件夹的功能 public class EditorProjectToolWi ...

  5. 从git仓库中删除.idea文件夹的小技巧

    这篇文章主要介绍了从git仓库中删除.idea文件夹的小妙招,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下 如果不配置.gitignore的文件,带push ...

  6. Java中 实现通过文件夹选择任一图像,从而进行图像卷积操作

    ** Java中 实现通过文件夹选择任一图像,从而进行图像卷积操作 ** 之前的那篇关于图像卷积的博客(Java中实现图像的卷积效果),只是讲了给定一张图片,从而实现图片的卷积操作:而现在,需要去实现 ...

  7. win10计算机里文件夹怎么删除文件,如何删除win10“此电脑”中6个文件夹?

    更新完win10系统,我们会发现打开"此电脑",相比win7相比,除了还有传统的硬盘分区外,还多了6个文件夹:视频.图片.文档.下载.音乐和桌面.讲真,这些文件夹似乎也用不上,对于 ...

  8. Winform中选取指定文件夹并获取其下所有文件

    场景 Winform中选取指定文件夹,并获取该文件夹下所有文件名,不包含子文件夹.考虑子文件夹可以使用递归实现. 注: 博客: BADAO_LIUMANG_QIZHI的博客_霸道流氓气质_CSDN博客 ...

  9. JDK中没有jre文件夹和tools.jar文件

    JDK中没有jre文件夹和tools.jar文件 ​ JDK在11版本以后再以前的基础上做了较大的改动,安装后默认是没有jre的.并且,再JDK8以后,JDK也发生了较大的变化,移除了tools.ja ...

最新文章

  1. python sip模块(为C和C++库创建Python绑定)
  2. UIbutton系统按键(System)和图片按键(Custom)对比
  3. 微服务架构--链路追踪(Nginx篇)
  4. netcore mvc快速开发系统(菜单,角色,权限[精确到按钮])开源
  5. 四款新旗舰即将发布:小米10和iPhone9领跑,价格惊喜
  6. 每日linux命令学习-历史指令查询(history、fc、alias)
  7. 数据双向绑定_手写 Vue3 数据双向绑定 理解Proxy
  8. php中ignore_user_abort函数的用法
  9. Lesson 01 for Plotting in R for Biologists
  10. 一直困扰我的String判空这回终于有解决办法了
  11. VOLTE信令流程-IMS注册篇(五)
  12. DNW5.0 USB 不OK
  13. 交换机怎么和计算机连接网络打印机,怎么通过地址栏的方式连接网络打印机的方法?...
  14. 初创公司几个投资人,各占多少股份合适?
  15. Postman INTERCEPTOR DISCONNECTED
  16. Payton编写日历代码
  17. 面试时,如何回答关于“缺点”的问题——大学生求职七大昏招衍生系列(2)
  18. 用Excel完成专业化数据统计、分析工作
  19. 新能源汽车,车架号VIN码查询接口
  20. Bulma的简单使用

热门文章

  1. Linux中echo 返回值的意思
  2. 写了一段VBA代码后, Excel每次保存时都弹出警告:”此文档中包含宏、Activex控件、XML扩展包信息“(office 2007)
  3. Excel中如何引用 「文件名」、「sheet 页」的名字
  4. Eclipse的自动build选项,制造时别忘了选上~
  5. 不记得撞得有多痛了,可是,那个电线杆,永远都在
  6. 网站服务器是租还是买,建站服务器是买还是租?编辑教你聪明选
  7. 成绩单表格html,【Web前端HTML5CSS3】15-表格
  8. 【Python】Python中的日志级别
  9. nodejs连接mysql数据库,报错Client does not support authentication protocol requested by server的解决方法
  10. 安装slide后Powerpoint 不自动退出的解决方案