Version: 2023.1
言語: 日本語

AssetBundle

class in UnityEngine

/

継承:Object

マニュアルに切り替える

説明

API for accessing the content of AssetBundle files.

This class exposes an API, via static methods, for loading and managing AssetBundles.

This same class offers non-static methods and properties that expose the contents of a specific loaded AssetBundle, including the ability to load an Asset from within an AssetBundle.

Create AssetBundles by calling BuildPipeline.BuildAssetBundles or using the Addressables package. The build process generates one or more AssetBundle files, and each AssetBundle file contains a serialized instance of this class.

Note: AssetBundle.LoadAsset, and the other Load methods, do not support loading Scenes from AssetBundles. Instead, once a streamed scene AssetBundle has been loaded you can call SceneManager.LoadScene or SceneManager.LoadSceneAsync.

See Also: Intro to AssetBundles, UnityWebRequestAssetBundle.GetAssetBundle, BuildPipeline.BuildAssetBundles.

using System.Collections;
using UnityEngine;
using UnityEngine.Networking;

public class SampleBehaviour : MonoBehaviour { IEnumerator Start() { var uwr = UnityWebRequestAssetBundle.GetAssetBundle("https://myserver/myBundle.unity3d"); yield return uwr.SendWebRequest();

// Get an asset from the bundle and instantiate it. AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(uwr); var loadAsset = bundle.LoadAssetAsync<GameObject>("Assets/Players/MainPlayer.prefab"); yield return loadAsset;

Instantiate(loadAsset.asset); } }

Static 変数

memoryBudgetKBControls the size of the shared AssetBundle loading cache. Default value is 1MB.

変数

isStreamedSceneAssetBundleReturn true if the AssetBundle contains Unity Scene files

Public 関数

Contains特定のオブジェクトがアセットバンドルに含まれているか確認します。
GetAllAssetNamesReturn all Asset names in the AssetBundle.
GetAllScenePathsReturn all the names of Scenes in the AssetBundle.
LoadAllAssetsLoads all Assets contained in the AssetBundle synchronously.
LoadAllAssetsAsyncLoads all Assets contained in the AssetBundle asynchronously.
LoadAssetSynchronously loads an Asset from the AssetBundle.
LoadAssetAsyncAsynchronously loads an Asset from the bundle.
LoadAssetWithSubAssetsLoads Asset and sub Assets from the AssetBundle synchronously.
LoadAssetWithSubAssetsAsyncLoads Asset and sub Assets from the AssetBundle asynchronously.
UnloadUnloads an AssetBundle freeing its data.
UnloadAsyncUnloads assets in the bundle.

Static 関数

GetAllLoadedAssetBundlesGet an enumeration of all the currently loaded AssetBundles.
LoadFromFileディスクから同期でアセットバンドルを読み込みます。
LoadFromFileAsyncディスクから非同期でアセットバンドルを読み込みます。
LoadFromMemorySynchronously load an AssetBundle from a memory region.
LoadFromMemoryAsyncAsynchronously load an AssetBundle from a memory region.
LoadFromStreamSynchronously loads an AssetBundle from a managed Stream.
LoadFromStreamAsyncAsynchronously loads an AssetBundle from a managed Stream.
RecompressAssetBundleAsyncAsynchronously recompress a downloaded/stored AssetBundle from one BuildCompression to another.
UnloadAllAssetBundlesUnloads all currently loaded AssetBundles.

継承メンバー

変数

hideFlagsShould the object be hidden, saved with the Scene or modifiable by the user?
nameオブジェクト名

Public 関数

GetInstanceIDGets the instance ID of the object.
ToStringReturns the name of the object.

Static 関数

DestroyRemoves a GameObject, component or asset.
DestroyImmediateDestroys the object obj immediately. You are strongly recommended to use Destroy instead.
DontDestroyOnLoadDo not destroy the target Object when loading a new Scene.
FindAnyObjectByTypeRetrieves any active loaded object of Type type.
FindFirstObjectByTypeRetrieves the first active loaded object of Type type.
FindObjectsByTypeRetrieves a list of all loaded objects of Type type.
Instantiateoriginal のオブジェクトをクローンします

Operator

boolオブジェクトが存在するかどうか
operator !=二つのオブジェクトが異なるオブジェクトを参照しているか比較します
operator ==2つのオブジェクト参照が同じオブジェクトを参照しているか比較します。