TriLib  1.9.0
TriLib Unity Package
TriLib.AssetDownloader Class Reference

Represents an asset downloader. Add this MonoBehaviour to any GameObject and set AssetURI and AssetExtension to automatically download the referenced model. More...

Inheritance diagram for TriLib.AssetDownloader:

Public Member Functions

bool DownloadAsset (string assetURI, string assetExtension, ObjectLoadedHandle onAssetLoaded=null, TexturePreLoadHandle onTexturePreLoad=null, AssetLoaderOptions options=null, GameObject wrapperGameObject=null, AssimpInterop.ProgressCallback progressCallback=null)
 Downloads an asset. More...
 

Public Attributes

bool AutoStart = true
 Turn on this field to start the download automatically. More...
 
string AssetURI
 Use this field to set the asset URI. More...
 
int Timeout = 2000
 Use this field to set the download timeout in seconds. More...
 
string AssetExtension
 Use this field to set the asset extension. (Eg: ".FBX") More...
 
GameObject WrapperGameObject
 Use this field to set the UnityEngine.GameObject to load the asset into. More...
 
bool ShowProgress
 Enable this field to show loading progress on GUI. More...
 
bool Async
 Enable this field to load models asynchronously. More...
 
AssimpInterop.ProgressCallback ProgressCallback
 Use this field to pass a method that will be called on model loading progress. More...
 

Protected Member Functions

void Start ()
 Checks the AssetURI and AssetExtension and starts downloading the asset, if both are avaliable. More...
 
void OnGUI ()
 Shows the progress on screen, if ShowProgress is set to true. More...
 

Properties

bool HasStarted [get]
 Gets a value indicating whether the download has started. More...
 
bool IsDone [get]
 Gets a value indicating whether the download is done. More...
 
string Error [get]
 Gets the last error message. More...
 
float Progress [get]
 Gets the download progress. More...
 

Detailed Description

Represents an asset downloader. Add this MonoBehaviour to any GameObject and set AssetURI and AssetExtension to automatically download the referenced model.

Enable TRILIB_USE_ZIP compiler symbol manually or tick "Enable Zip loading" on TriLib menu to enable ZIP files processing.

Member Function Documentation

◆ DownloadAsset()

bool TriLib.AssetDownloader.DownloadAsset ( string  assetURI,
string  assetExtension,
ObjectLoadedHandle  onAssetLoaded = null,
TexturePreLoadHandle  onTexturePreLoad = null,
AssetLoaderOptions  options = null,
GameObject  wrapperGameObject = null,
AssimpInterop.ProgressCallback  progressCallback = null 
)

Downloads an asset.

Returns
true, if asset was downloaded, false otherwise.
Parameters
assetURIAsset URI.
assetExtensionAsset extension.
onAssetLoadedOn asset loaded event.
onTexturePreLoadOn texture pre load event.
optionsAsset loading options.
wrapperGameObjectWrapper UnityEngine.GameObject to load the asset into.
progressCallbackCallback used to retrieve file loading percentage.

◆ OnGUI()

void TriLib.AssetDownloader.OnGUI ( )
protected

Shows the progress on screen, if ShowProgress is set to true.

◆ Start()

void TriLib.AssetDownloader.Start ( )
protected

Checks the AssetURI and AssetExtension and starts downloading the asset, if both are avaliable.

Member Data Documentation

◆ AssetExtension

string TriLib.AssetDownloader.AssetExtension

Use this field to set the asset extension. (Eg: ".FBX")

Use ".ZIP" for ZIP files.

◆ AssetURI

string TriLib.AssetDownloader.AssetURI

Use this field to set the asset URI.

◆ Async

bool TriLib.AssetDownloader.Async

Enable this field to load models asynchronously.

◆ AutoStart

bool TriLib.AssetDownloader.AutoStart = true

Turn on this field to start the download automatically.

◆ ProgressCallback

AssimpInterop.ProgressCallback TriLib.AssetDownloader.ProgressCallback

Use this field to pass a method that will be called on model loading progress.

◆ ShowProgress

bool TriLib.AssetDownloader.ShowProgress

Enable this field to show loading progress on GUI.

◆ Timeout

int TriLib.AssetDownloader.Timeout = 2000

Use this field to set the download timeout in seconds.

◆ WrapperGameObject

GameObject TriLib.AssetDownloader.WrapperGameObject

Use this field to set the UnityEngine.GameObject to load the asset into.

Property Documentation

◆ Error

string TriLib.AssetDownloader.Error
get

Gets the last error message.

The error message.

◆ HasStarted

bool TriLib.AssetDownloader.HasStarted
get

Gets a value indicating whether the download has started.

true if this download has started; otherwise, false.

◆ IsDone

bool TriLib.AssetDownloader.IsDone
get

Gets a value indicating whether the download is done.

true if this download is done; otherwise, false.

◆ Progress

float TriLib.AssetDownloader.Progress
get

Gets the download progress.

The download progress.


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