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 使用的特殊文件夹名称的完整列表。
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 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 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 文件夹的确切位置会影响其脚本相对于其他脚本的编译时间。参阅特殊文件夹和脚本编译顺序上的文档了解完整的描述。
Use the EditorGUIUtility.Load function in Editor scripts to load Assets from a Resources folder within an Editor folder. These Assets are only loaded through Editor scripts and are stripped from builds.
注意:如果脚本位于 Editor 文件夹中,Unity 不允许将派生自 MonoBehaviour 的组件分配给游戏对象。
Editor 脚本可以使用通过 EditorGUIUtility.Load 函数按需加载的资源文件。此函数在名为 Editor Default Resources 的文件夹中查找资源文件。
You can only have one Editor Default Resources folder and you must place it in Project root, 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 允许将图形添加到 Scene 视图,以帮助可视化不可见的设计细节。Gizmos.DrawIcon 函数在场景中放置一个图标,作为特殊对象或位置的标记。必须将用于绘制此图标的图像文件放在名为 Gizmos 的文件夹中,这样才能被 DrawIcon 函数找到。
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.
可从脚本中按需加载资源,而不必在场景中创建资源实例以用于游戏。为此,应将资源放在一个名为 Resources 的文件夹中。通过使用 Resources.Load 函数即可加载这些资源。
可在 Assets 文件夹中的任何位置添加多个 Resources 文件夹。将所需的资源文件放在 Resources 文件夹内或其中的子文件夹内。如果资源文件位于子文件夹中,请始终在传递给 Resources.Load 函数的路径中包含子文件夹路径。
Note: If the Resources folder is an Editor subfolder, the Assets in it are loadable from Editor scripts but are removed from builds.
When you import a Standard Asset package, Unity puts the assets in a folder called Standard Assets
. In addition to containing the assets, these folders 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.
You may want the Asset to be available as a separate file in its original format (though it’s more common to directly incorporate Assets into a build). For example, you need to access a video file from the filesystem to play the video on IOS using Handheld.PlayFullScreenMovie.
要包含流媒体资源,请执行以下操作:
请参阅关于流媒体资源的页面以了解更多详细信息。
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 Assets files in the StreamingAssets folder or subfolder. Always include the subfolder path in the path used to reference the streaming asset if your Asset files are in subfolders.
Unity interprets any folder that ends with .androidpack
as an Android asset packs. For more information, see Create a custom asset pack.
Unity interprets any folder that ends with .androidlib
as an Android Library Project. For more information, see Import and Android Library Project.
在导入过程中,Unity 忽略 Assets 文件夹(或其子文件夹)中的以下文件和文件夹:
这可以防止导入由操作系统或其他应用程序创建的特殊文件和临时文件。