Version: 2022.2
언어: 한국어

AssetBundle

class in UnityEngine

/

다음으로부터 상속:Object

매뉴얼로 전환

설명

AssetBundles let you stream additional assets via the UnityWebRequest class and instantiate them at runtime.

Create AssetBundles by calling BuildPipeline.BuildAssetBundles or using the Scriptable Build Pipeline package.

A bundle built for any of the standalone platforms can only be loaded on that platform, for example a bundle build on iOS is not compatible with Android. This is because shaders, textures and other types of data are built into platform-specific formats based on the BuildTarget.

See Also: UnityWebRequestAssetBundle.GetAssetBundle, Loading Resources at Runtime, 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); } }

정적 변수

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

변수

isStreamedSceneAssetBundleReturn true if the AssetBundle is a streamed Scene AssetBundle.

Public 함수

ContainsCheck if an AssetBundle contains a specific object.
GetAllAssetNamesReturn all asset names in the AssetBundle.
GetAllScenePathsReturn all the Scene asset paths (paths to *.unity assets) in the AssetBundle.
LoadAllAssetsLoads all assets contained in the asset bundle that inherit from type.
LoadAllAssetsAsyncLoads all assets contained in the asset bundle asynchronously.
LoadAssetLoads asset with name from the bundle.
LoadAssetAsyncAsynchronously loads asset with name from the bundle.
LoadAssetWithSubAssetsLoads asset and sub assets with name from the bundle.
LoadAssetWithSubAssetsAsyncLoads asset with sub assets with name from the bundle asynchronously.
UnloadUnloads an AssetBundle freeing its data.
UnloadAsyncUnloads assets in the bundle.

정적 함수

GetAllLoadedAssetBundlesTo use when you need to get a list of all the currently loaded Asset Bundles.
LoadFromFileSynchronously loads an AssetBundle from a file on disk.
LoadFromFileAsyncAsynchronously loads an AssetBundle from a file on disk.
LoadFromMemorySynchronously create an AssetBundle from a memory region.
LoadFromMemoryAsyncAsynchronously create 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?
nameThe name of the object.

Public 함수

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

정적 함수

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.
FindObjectOfTypeReturns the first active loaded object of Type type.
FindObjectsByTypeRetrieves a list of all loaded objects of Type type.
FindObjectsOfTypeGets a list of all loaded objects of Type type.
InstantiateClones the object original and returns the clone.

연산자

boolDoes the object exist?
operator !=Compares if two objects refer to a different object.
operator ==Compares two object references to see if they refer to the same object.