版本:Unity 6 (6000.0)
语言中文
  • C#

BuildAssetBundleOptions.DisableLoadAssetByFileName

提出修改建议

成功!

感谢您帮助我们改进 Unity 文档的质量。尽管我们无法接受所有的提交,但我们确实会阅读用户提出的每一条修改建议,并会在适用情况下进行更新。

关闭

提交失败

由于某种原因,您提出的修改建议无法提交。请在几分钟后<a>重试</a>。感谢您抽出时间帮助我们改进 Unity 文档的质量。

关闭

取消

描述

禁用 Asset Bundle LoadAsset 按文件名查找。

默认情况下,Asset Bundle 有三种查找相同资源的方法:完整资源路径、资源文件名以及带扩展名的资源文件名。完整路径序列化到 Asset Bundle 中,而文件名和带扩展名的文件名在从文件中加载 Asset Bundle 时生成。

示例:“Assets/Prefabs/Player.prefab”,“Player”和“Player.prefab”

此选项将在 Asset Bundle 中设置一个标志来防止创建资源文件名查找。此选项可节省运行时内存并提高资源包的加载性能。

其他资源:BuildAssetBundleOptions.DisableLoadAssetByFileNameLoadingWithExtension。

//Create a folder (right click in the Assets folder and go to Create>Folder), and name it “Editor” if it doesn’t already exist
//Place this script in the Editor folder

//This script creates a new Menu named “Build Asset” and new options within the menu named “Normal” and “Disable Load Asset By filename”. Click these menu items to build an AssetBundle into a folder.

using UnityEngine; using UnityEditor;

public class Example { //Creates a new menu (Build Asset Bundles) and item (Normal) in the Editor [MenuItem("Build Asset Bundles/Normal")] static void BuildABsNone() { //Build AssetBundles with no special options //They will be written in the custom folder ("MyAssetBuilds") which needs to exist prior to this call. BuildPipeline.BuildAssetBundles("Assets/MyAssetBuilds", BuildAssetBundleOptions.None, BuildTarget.StandaloneOSX); }

//Creates a new item (Disable Load Asset By Name) in the new Build Asset Bundles menu [MenuItem("Build Asset Bundles/Disable Load Asset By Name")] static void BuildABsDisable() { //Build the AssetBundles in this mode BuildPipeline.BuildAssetBundles("Assets/MyAssetBuilds", BuildAssetBundleOptions.DisableLoadAssetByFileName, BuildTarget.StandaloneOSX); } }