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

BuildAssetBundleOptions.DisableLoadAssetByFileNameWithExtension

建议修改

成功!

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

关闭

提交失败

由于某些原因,您的修改建议无法提交。请<a>稍后再试</a>。感谢您抽出时间帮助我们提高 Unity 文档的质量。

关闭

取消

描述

禁用通过文件名(含扩展名)加载资源包。

资源包默认有三种查找同一资源的方式:完整资源路径、资源文件名和资源文件名(含扩展名)。完整路径会被序列化到资源包中,而文件名和文件名(含扩展名)是在从文件加载资源包时生成的。

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

此选项将在资源包上设置一个标志,以防止创建文件名(含扩展名)查找。此选项可以节省资源包的运行时内存和加载性能。

其他资源:BuildAssetBundleOptions.DisableFileNameLoading。

//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 with Extension”. 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 with Extension) in the new Build Asset Bundles menu [MenuItem("Build Asset Bundles/Disable Load Asset By Name with Extension ")] static void BuildABsDisable() { //Build the AssetBundles in this mode BuildPipeline.BuildAssetBundles("Assets/MyAssetBuilds", BuildAssetBundleOptions.DisableLoadAssetByFileNameWithExtension, BuildTarget.StandaloneOSX); } }