Version: 2021.1

AssetDatabase.GetAssetPathsFromAssetBundleAndAssetName

切换到手册
public static string[] GetAssetPathsFromAssetBundleAndAssetName (string assetBundleName, string assetName);

描述

获取所有标有 assetBundleName 且有指定 assetName 的 资源的资源路径。

获取所有标有 assetBundleName 且有指定 assetName 的 资源的资源路径,与其扩展名或路径无关, 例如当 assetName 为"House"时,资产的路径可为 "Assets/House.prefab", "Assets/Textures/House.png" 和 "Assets/Data/House.xml"。

using UnityEditor;
using UnityEngine;

public class ExampleScript { [MenuItem("AssetDatabase/Display assets in an AssetBundle")] static void ExampleScriptCode1() { string[] assetPaths = AssetDatabase.GetAssetPathsFromAssetBundleAndAssetName("assetname", "House"); foreach (var assetPath in assetPaths) Debug.Log(assetPath); }

[MenuItem("AssetDatabase/AssetBundle creation")] static void ExampleScriptCode2() { BuildPipeline.BuildAssetBundles("Assets/AssetBundles", BuildAssetBundleOptions.None, BuildTarget.StandaloneOSX); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961