Version: 2021.3
AssetDatabase 批处理
Import Activity window

特殊文件夹名称

You can usually choose any name you like for the folders you create to organize your Unity project. However, there are folder names that Unity reserves for special purposes. For example, you must place Editor scripts in a folder called Editor for them to work correctly.

本页面包含 Unity 使用的特殊文件夹名称的完整列表。

Assets

Assets 文件夹是包含 Unity 项目使用的资源的主文件夹。Editor 中的 Project 窗口的内容直接对应于 Assets 文件夹的内容。大多数 API 函数都假定所有内容都位于 Assets 文件夹中,因此不要求显式提及该文件夹。但是,有些函数需要将 Assets 文件夹作为路径名的一部分添加(例如,AssetDatabase 类中的一些函数)。

Editor

Editor scripts add functionality to Unity during development, but aren’t available in builds at runtime. Scripts in an Editor folder run as Editor scripts, not runtime scripts.

可在 Assets 文件夹中的任何位置添加多个 Editor 文件夹。应将 Editor 脚本放在 Editor 文件夹内或其中的子文件夹内。

Editor 文件夹的确切位置会影响其脚本相对于其他脚本的编译时间。参阅特殊文件夹和脚本编译顺序上的文档了解完整的描述。

使用 Editor 脚本中的 EditorGUIUtility.Load 函数可从 Editor 文件夹中的 Resources 文件夹加载资源。这些资源只能通过 Editor 脚本加载,并会从构建中剥离。

注意:如果脚本位于 Editor 文件夹中,Unity 不允许将派生自 MonoBehaviour 的组件分配给游戏对象。

Editor Default Resources

Editor 脚本可以使用通过 EditorGUIUtility.Load 函数按需加载的资源文件。此函数在名为 Editor Default Resources 的文件夹中查找资源文件。

只能有一个 Editor Default Resources 文件夹,且必须将其放在项目的根目录中;直接位于 Assets 文件夹中。将所需的资源文件放在此 Editor Default Resources 文件夹内或其中的子文件夹内。如果资源文件位于子文件夹中,请始终在传递给 EditorGUIUtility.Load 函数的路径中包含子文件夹路径。

Gizmos

Gizmos 允许将图形添加到 Scene 视图,以帮助可视化不可见的设计细节。Gizmos.DrawIcon 函数在场景中放置一个图标,作为特殊对象或位置的标记。必须将用于绘制此图标的图像文件放在名为 Gizmos 的文件夹中,这样才能被 DrawIcon 函数找到。

只能有一个 Gizmos 文件夹,且必须将其放在项目的根目录,直接位于 Assets 文件夹中。将所需的资源文件放在此 Gizmos 文件夹内或其中的子文件夹内。如果资源文件位于子文件夹中,请始终在传递给 Gizmos.DrawIcon 函数的路径中包含子文件夹路径。

Resources

可从脚本中按需加载资源,而不必在场景中创建资源实例以用于游戏。为此,应将资源放在一个名为 Resources 的文件夹中。通过使用 Resources.Load 函数即可加载这些资源。

可在 Assets 文件夹中的任何位置添加多个 Resources 文件夹。将所需的资源文件放在 Resources 文件夹内或其中的子文件夹内。如果资源文件位于子文件夹中,请始终在传递给 Resources.Load 函数的路径中包含子文件夹路径。

注意:如果 Resources 文件夹是 Editor 的子文件夹,则其中的资源可通过 Editor 脚本加载,但会从构建中删除。

Standard Assets

When you import a Standard Asset package, Unity puts the assets in a folder called Standard Assets. As well as containing the assets, these folders also have an effect on script compilation order. For more information, see the page on Special Folders and Script Compilation Order.

You can only have one Standard Assets folder and you must leave it in the root of the project, directly within the Assets folder. Place the asset files you need inside the <project-root>/Assets/Standard Assets folder or one of its subfolders.

StreamingAssets

尽管将资源直接合并到构建中更为常见(但有时可能希望资源以其原始格式作为单独的文件提供)。例如,您需要使用 Handheld.PlayFullScreenMovie 从文件系统访问一个视频文件,以便在 IOS 上播放。

要包含流媒体资源,请执行以下操作:

  1. 将文件放在 StreamingAssets 文件夹中。
  2. 该文件在复制到目标机器时保持不变,它可以从特定文件夹中获得。

请参阅关于流媒体资源的页面以了解更多详细信息。

只能有一个 StreamingAssets 文件夹,且必须将其放在项目的根目录,直接位于 Assets 文件夹中。将资源文件放在 StreamingAssets 文件夹或其子文件夹内。如果资源文件位于子文件夹中,请始终在用于引用流媒体资源的路径中包含子文件夹路径。

Android Asset Packs

Unity interprets any folder that ends with .androidpack as an Android asset packs. For more information, see Create a custom asset pack.

Android 库项目

Unity interprets any folder that ends with .androidlib as an Android Library Project. For more information, see Import and Android Library Project.

隐藏的资源

在导入过程中,Unity 忽略 Assets 文件夹(或其子文件夹)中的以下文件和文件夹:

  • 隐藏的文件夹。
  • 以“.”开头的文件和文件夹。
  • 以“~”结尾的文件和文件夹。
  • 名为 cvs 的文件和文件夹。
  • 扩展名为 .tmp 的文件。

这可以防止导入由操作系统或其他应用程序创建的特殊文件和临时文件。

AssetDatabase 批处理
Import Activity window
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961