Easy Content Delivery Network 1.3.2
An addressables-free suite that automatically handles the Unity Cloud Content Delivery API and packaging/deploying assetbundles while providing several tools to make asset management easy.
Loading...
Searching...
No Matches
SplenSoft.AssetBundles.AssetBundleManager Class Reference

Static class that manages asset bundle retrieval and packaging. More...

Static Public Member Functions

static bool TryGetAssetBundleData (string assetBundleName, out AssetBundleData data)
 Attempts to return AssetBundleData for an asset bundle. The AssetBundleManager must be initialized for the manifest data to be available.
 
static bool TryGetAssetRetrievalResult (string assetBundleName, out AssetRetrievalResult result)
 Gets status of last download attempt for an asset. Note: If an asset was pulled from the cache, it will return 200 with UnityWebRequest.Result.Success. To get the result of the initialization attempt (downloading the manifest), use TryGetAssetManifestRetrievalResult
 
static bool TryGetAssetManifestRetrievalResult (out AssetRetrievalResult result)
 Gets status of last download attempt of the project asset bundle manifest for this platform. Note: If the plugin is set to use editor assets and this is running in an editor, it will return 200 with UnityWebRequest.Result.Success.
 
static async Task< AssetBundleManifest > GetManifest ()
 Downloads and unpacks the AssetBundleManifest for this platform from the CDN.
 
static void SetSelfInitializerTimeout (float timeInSeconds)
 Sets a time, in seconds, that the Asset Bundle Manager will attempt to auto-initialize.
 
static async void Initialize ()
 Downloads the project asset bundle manifest for this platform and caches the dependency data. Called automatically on app start unless AutoInitialize is set to false on app awake.
 
static async Task< bool > DoesBucketExist (string bucketId)
 Uses client-facing Unity Cloud Content Delivery APIto determine if a bucket exists. Requires an internet connection.
 
static async Task< string[]> GetAssetBundleNames (string regexPattern)
 If runtime, requires plugin to be initialzied and Initialized must be true. Scans manifest for all asset bundle names. If running in the editor with Use Editor Assets checked in the settings, it will scan the project's AssetDatabase
 
static async Task< string[]> GetAssetBundleNames (Type type)
 If runtime, requires plugin to be initialzied and Initialized must be true. Scans manifest for all asset bundle names. If running in the editor with Use Editor Assets checked in the settings, it will scan the project's AssetDatabase
 
static async Task< T > GetAsset< T > (string name, IProgress< AssetRetrievalProgress > progress=null, Action< T > onSuccess=null, Action< AssetRetrievalResult > onFailure=null, bool waitForInitialize=true)
 Downloads an asset bundle from the Unity Content Delivery cloud and unpacks the asset.
 
static async Task< AssetBundle > GetAssetBundle (string name, IProgress< AssetRetrievalProgress > progress=null, Action< AssetBundle > onSuccess=null, Action< AssetRetrievalResult > onFailure=null, bool waitForInitialize=true)
 Downloads an asset bundle from the Unity Content Delivery cloud.
 
static async Task LoadSceneAsssetBundle (string name, IProgress< AssetRetrievalProgress > progress=null, Action onSuccess=null, Action< AssetRetrievalResult > onFailure=null, bool waitForInitialize=true)
 Downloads a scene asset bundle from the Unity Content Delivery cloud and immediately loads it.
 
static async Task DownloadAndCacheDependencies (string assetBundleName, IProgress< AssetRetrievalProgress > progress=null)
 Downloads all of an AssetBundle's dependencies and keeps them cached. Good for loading ahead to make downloading a later asset bundle quicker.
 
static async Task< List< string > > GetDependencies (string assetBundleName)
 Returns all of an asset's dependencies. Does not check Initialized.
 
static async Task< List< T > > GetAllAssetsOfType< T > (IProgress< AssetRetrievalProgress > progress=null)
 Gets all ScriptableObject assets of a certain type from the CDN.
 
static bool TryGetAssetBundleName (UnityEngine.Object obj, out string assetBundleName)
 Attempts to retrieve or generate asset bundle name. Will fail if asset type is not defined in EZCDN settings.
 
static void RunCliCommands (List< string > commands, out List< string > output, bool verbose=true)
 EDITOR ONLY: Will use the included Unity Cloud Content Delivery CLI executable for this Unity Editor platform to execute commands. Refer to the Unity CLI documentation for commands. Note: This will automatically log in with the provided API key in the plugin settings, so there's no need to provide an 'auth login' command. This will also automatically append the current environment id to each command, so there's no need to append –environment [id].
 

Properties

static UnityEvent< string > AssetRetrievalStarted = new UnityEvent<string>() [get]
 Fires when GetAsset is called.
 
static UnityEvent< string > AssetLoaded = new UnityEvent<string>() [get]
 Fires when GetAsset is finished and asset is fully loaded, ready to instantiate. Note: Only fires if the asset is not already loaded. Subsequent calls will not trigger this event unless is called on the data.
 
static UnityEvent< string > AssetBundleDownloadStarted = new UnityEvent<string>() [get]
 Fires when GetAssetBundle is called.
 
static UnityEvent< string > AssetBundleDownloadFinished = new UnityEvent<string>() [get]
 Fires when GetAssetBundle is finished and asset bundle has completed downloading. Note that this does not mean the asset has been loaded. Subscribe to AssetLoaded to know when the asset has been loaded.
 
static UnityEvent< string > SceneAssetRetrievalStarted = new UnityEvent<string>() [get]
 Fires when LoadSceneAssetBundle is called.
 
static UnityEvent< string > SceneAssetLoaded = new UnityEvent<string>() [get]
 Fires when LoadSceneAssetBundle is finished and scene is fully loaded.
 
static bool AutoInitialize = true [get, set]
 Set to false to disable the auto initialization (retrieval of AssetBundleManifest and caching dependencies). Note: You must set this to false immedately when the app starts to avoid the first initialization attempt. Best practice would be to use a gameobject that calls awake in the inital scene in the game.
 
static bool IsPackagingAssets [get]
 Returns true if the Asset Bundle Manager is currently processing and packaging assets on an AssetBundles -> Build command.
 

Detailed Description

Static class that manages asset bundle retrieval and packaging.

Member Function Documentation

◆ DoesBucketExist()

static async Task< bool > SplenSoft.AssetBundles.AssetBundleManager.DoesBucketExist ( string bucketId)
static

Uses client-facing Unity Cloud Content Delivery APIto determine if a bucket exists. Requires an internet connection.

Parameters
bucketIdBucket ID, can be pulled from AssetBundleManagerSettings
Returns
True if bucket exists on the Unity CDN

◆ DownloadAndCacheDependencies()

static async Task SplenSoft.AssetBundles.AssetBundleManager.DownloadAndCacheDependencies ( string assetBundleName,
IProgress< AssetRetrievalProgress > progress = null )
static

Downloads all of an AssetBundle's dependencies and keeps them cached. Good for loading ahead to make downloading a later asset bundle quicker.

Parameters
assetBundleNameThe name of the AssetBundle
progressTrackable progress reporter
Returns
A Task object

◆ GetAllAssetsOfType< T >()

static async Task< List< T > > SplenSoft.AssetBundles.AssetBundleManager.GetAllAssetsOfType< T > ( IProgress< AssetRetrievalProgress > progress = null)
static

Gets all ScriptableObject assets of a certain type from the CDN.

Template Parameters
TA class deriving from ScriptableObject
Returns
A list of ScriptableObjects of the specified type
Type Constraints
T :ScriptableObject 

◆ GetAsset< T >()

static async Task< T > SplenSoft.AssetBundles.AssetBundleManager.GetAsset< T > ( string name,
IProgress< AssetRetrievalProgress > progress = null,
Action< T > onSuccess = null,
Action< AssetRetrievalResult > onFailure = null,
bool waitForInitialize = true )
static

Downloads an asset bundle from the Unity Content Delivery cloud and unpacks the asset.

Parameters
nameThe name of the AssetBundle
progressTrackable progress reporter
waitForInitializeThe task will wait for the Asset Bundle Manager to initialize (retrieve its manifest for dependencies) before requesting the asset. Strongly recommended to leave this as default (true) unless you have a very special case (like retrieving the manifest manually)
onSuccessAction which is invoked on successful retrieval
onFailureAction which is invoked on failed retrieval
Returns
A Task object with a result of type T
Type Constraints
T :UnityEngine.Object 

◆ GetAssetBundle()

static async Task< AssetBundle > SplenSoft.AssetBundles.AssetBundleManager.GetAssetBundle ( string name,
IProgress< AssetRetrievalProgress > progress = null,
Action< AssetBundle > onSuccess = null,
Action< AssetRetrievalResult > onFailure = null,
bool waitForInitialize = true )
static

Downloads an asset bundle from the Unity Content Delivery cloud.

Parameters
nameThe name of the AssetBundle
progressTrackable progress reporter
waitForInitializeThe task will wait for the Asset Bundle Manager to initialize (retrieve its manifest for dependencies) before requesting the asset. Strongly recommended to leave this as default (true) unless you have a very special case (like retrieving the manifest manually)
onSuccessAction which is invoked on successful retrieval
onFailureAction which is invoked on failed retrieval
Returns
A Task object with an AssetBundle result

◆ GetAssetBundleNames() [1/2]

static async Task< string[]> SplenSoft.AssetBundles.AssetBundleManager.GetAssetBundleNames ( string regexPattern)
static

If runtime, requires plugin to be initialzied and Initialized must be true. Scans manifest for all asset bundle names. If running in the editor with Use Editor Assets checked in the settings, it will scan the project's AssetDatabase

Parameters
regexPatternA regex to match against the asset bundle names
Returns
All asset bundle names that matched the regex

◆ GetAssetBundleNames() [2/2]

static async Task< string[]> SplenSoft.AssetBundles.AssetBundleManager.GetAssetBundleNames ( Type type)
static

If runtime, requires plugin to be initialzied and Initialized must be true. Scans manifest for all asset bundle names. If running in the editor with Use Editor Assets checked in the settings, it will scan the project's AssetDatabase

Parameters
typeTranslates a type to a string that follows the standard asset naming format of EZ-CDN: typename_guid
Returns
All asset bundle names that matched typename_guid

◆ GetDependencies()

static async Task< List< string > > SplenSoft.AssetBundles.AssetBundleManager.GetDependencies ( string assetBundleName)
static

Returns all of an asset's dependencies. Does not check Initialized.

Parameters
assetBundleName
Returns
A list of AssetBundle names as strings

◆ GetManifest()

static async Task< AssetBundleManifest > SplenSoft.AssetBundles.AssetBundleManager.GetManifest ( )
static

Downloads and unpacks the AssetBundleManifest for this platform from the CDN.

Returns
The AssetBundleManifest for this platform

◆ LoadSceneAsssetBundle()

static async Task SplenSoft.AssetBundles.AssetBundleManager.LoadSceneAsssetBundle ( string name,
IProgress< AssetRetrievalProgress > progress = null,
Action onSuccess = null,
Action< AssetRetrievalResult > onFailure = null,
bool waitForInitialize = true )
static

Downloads a scene asset bundle from the Unity Content Delivery cloud and immediately loads it.

Parameters
nameThe name of the AssetBundle
progressTrackable progress reporter
waitForInitializeThe task will wait for the Asset Bundle Manager to initialize (retrieve its manifest for dependencies) before requesting the asset. Strongly recommended to leave this as default (true) unless you have a very special case (like retrieving the manifest manually)
onSuccessAction which is invoked on successful retrieval
onFailureAction which is invoked on failed retrieval
Returns
A Task object

◆ RunCliCommands()

static void SplenSoft.AssetBundles.AssetBundleManager.RunCliCommands ( List< string > commands,
out List< string > output,
bool verbose = true )
static

EDITOR ONLY: Will use the included Unity Cloud Content Delivery CLI executable for this Unity Editor platform to execute commands. Refer to the Unity CLI documentation for commands. Note: This will automatically log in with the provided API key in the plugin settings, so there's no need to provide an 'auth login' command. This will also automatically append the current environment id to each command, so there's no need to append –environment [id].

Parameters
commands
outputOutput from cmd.exe or /bin/bash after running the supplied commands
verboseWill append '–verbose' after every command. Strongly recommended to leave as default (true)

◆ SetSelfInitializerTimeout()

static void SplenSoft.AssetBundles.AssetBundleManager.SetSelfInitializerTimeout ( float timeInSeconds)
static

Sets a time, in seconds, that the Asset Bundle Manager will attempt to auto-initialize.

Parameters
timeInSecondsShould be a value >= 1

◆ TryGetAssetBundleData()

static bool SplenSoft.AssetBundles.AssetBundleManager.TryGetAssetBundleData ( string assetBundleName,
out AssetBundleData data )
static

Attempts to return AssetBundleData for an asset bundle. The AssetBundleManager must be initialized for the manifest data to be available.

Returns
True if the asset bundle data exists in the library

◆ TryGetAssetBundleName()

static bool SplenSoft.AssetBundles.AssetBundleManager.TryGetAssetBundleName ( UnityEngine::Object obj,
out string assetBundleName )
static

Attempts to retrieve or generate asset bundle name. Will fail if asset type is not defined in EZCDN settings.

Returns
True if asset bundle name was found or generated

◆ TryGetAssetManifestRetrievalResult()

static bool SplenSoft.AssetBundles.AssetBundleManager.TryGetAssetManifestRetrievalResult ( out AssetRetrievalResult result)
static

Gets status of last download attempt of the project asset bundle manifest for this platform. Note: If the plugin is set to use editor assets and this is running in an editor, it will return 200 with UnityWebRequest.Result.Success.

Returns
True if at least one attempt was made to retrieve the manifest prior to this call

◆ TryGetAssetRetrievalResult()

static bool SplenSoft.AssetBundles.AssetBundleManager.TryGetAssetRetrievalResult ( string assetBundleName,
out AssetRetrievalResult result )
static

Gets status of last download attempt for an asset. Note: If an asset was pulled from the cache, it will return 200 with UnityWebRequest.Result.Success. To get the result of the initialization attempt (downloading the manifest), use TryGetAssetManifestRetrievalResult

Returns
True if the asset existed in the manifest (and the plugin was properly initialized), and at least one attempt was made to retrieve the asset prior to this call

The documentation for this class was generated from the following files: