Version: 2023.2
言語: 日本語
public static Object[] LoadAllAssetsAtPath (string assetPath);

パラメーター

assetPath アセットのファイルシステム上のパス

説明

assetPath のすべてのアセットを含む配列を返します。

Some Asset files may contain multiple sub Assets (such as a Maya file which may contain multiple Meshes and GameObjects).
All paths are relative to the project folder, for example: "Assets/MyTextures/hello.png".
This function returns the main Asset and all sub Assets at a given path, including those hidden in the Project view.

Note: The main asset is not guaranteed to be at index 0 in the array

See Also: AssetDatabase.LoadMainAssetAtPath, AssetDatabase.LoadAllAssetRepresentationsAtPath, AssetDatabase.AddObjectToAsset, HideFlags.HideInHierarchy, EditorUtility.UnloadUnusedAssetsImmediate.

using UnityEngine;
using UnityEditor;

public class Example : MonoBehaviour { [MenuItem("AssetDatabase/LoadAllAssetsAtPath")] private static void PrintAssets() { Object[] data = AssetDatabase.LoadAllAssetsAtPath("Assets/MySpriteTexture.png");

Debug.Log(data.Length + " Assets");

foreach (Object o in data) { Debug.Log(o); }

// outputs: // 5 Assets // MySpriteTexture (UnityEngine.Texture2D) // MyTexture_0 (UnityEngine.Sprite) // MyTexture_1 (UnityEngine.Sprite) // MyTexture_2 (UnityEngine.Sprite) // MyTexture_3 (UnityEngine.Sprite) } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961