TriLib 2.3.8
Loading...
Searching...
No Matches
Static Public Member Functions | List of all members
TriLibCore.AssetLoader Class Reference

Represents the main class containing methods to load the Models. More...

Static Public Member Functions

static AssetLoaderContext LoadModelFromFile (string path, Action< AssetLoaderContext > onLoad=null, Action< AssetLoaderContext > onMaterialsLoad=null, Action< AssetLoaderContext, float > onProgress=null, Action< IContextualizedError > onError=null, GameObject wrapperGameObject=null, AssetLoaderOptions assetLoaderOptions=null, object customContextData=null, bool haltTask=false, Action< AssetLoaderContext > onPreLoad=null, bool isZipFile=false)
 Loads a Model from the given path asynchronously.
 
static AssetLoaderContext LoadModelFromStream (Stream stream, string filename=null, string fileExtension=null, Action< AssetLoaderContext > onLoad=null, Action< AssetLoaderContext > onMaterialsLoad=null, Action< AssetLoaderContext, float > onProgress=null, Action< IContextualizedError > onError=null, GameObject wrapperGameObject=null, AssetLoaderOptions assetLoaderOptions=null, object customContextData=null, bool haltTask=false, Action< AssetLoaderContext > onPreLoad=null, bool isZipFile=false)
 Loads a Model from the given Stream asynchronously.
 
static AssetLoaderContext LoadModelFromFileNoThread (string path, Action< IContextualizedError > onError=null, GameObject wrapperGameObject=null, AssetLoaderOptions assetLoaderOptions=null, object customContextData=null, bool isZipFile=false)
 Loads a Model from the given path synchronously.
 
static AssetLoaderContext LoadModelFromStreamNoThread (Stream stream, string filename=null, string fileExtension=null, Action< IContextualizedError > onError=null, GameObject wrapperGameObject=null, AssetLoaderOptions assetLoaderOptions=null, object customContextData=null, bool isZipFile=false)
 Loads a Model from the given Stream synchronously.
 
static AssetLoaderOptions CreateDefaultLoaderOptions (bool generateAssets=false, bool supressWarning=false)
 Creates an Asset Loader Options with the default settings and Mappers.
 
static ScriptableObject LoadOrCreateScriptableObjectSafe (string typeName, string typeNamespace, string directory, bool instantiate)
 Tries to load an ScriptableObject, or creates it with the given parameters if the ScriptableObject can't be found.
 
static MaterialMapper GetSelectedMaterialMapper (bool instantiate)
 Returns the Material Mapper configured for the Unity project.
 
static string GetCompatibleMaterialMapperName ()
 Gets the name of a compatible Material Mapper based on the render pipeline.
 

Detailed Description

Represents the main class containing methods to load the Models.

Member Function Documentation

◆ CreateDefaultLoaderOptions()

static AssetLoaderOptions TriLibCore.AssetLoader.CreateDefaultLoaderOptions ( bool  generateAssets = false,
bool  supressWarning = false 
)
static

Creates an Asset Loader Options with the default settings and Mappers.

Parameters
generateAssetsIndicates whether created Scriptable Objects will be saved as assets.
supressWarningPass trueif you are caching your AssetLoaderOptions instance.
Returns
The Asset Loader Options containing the default settings.

◆ GetCompatibleMaterialMapperName()

static string TriLibCore.AssetLoader.GetCompatibleMaterialMapperName ( )
static

Gets the name of a compatible Material Mapper based on the render pipeline.

Returns
The Material Mapper name, if found. Otherwise null.

◆ GetSelectedMaterialMapper()

static MaterialMapper TriLibCore.AssetLoader.GetSelectedMaterialMapper ( bool  instantiate)
static

Returns the Material Mapper configured for the Unity project.

Parameters
instantiatePass true to instantiate a new Material Mapper, or false to use the Material Mapper prefab instead.
Returns
The Material Mapper configured for the project, if there is any. Otherwise, null.

◆ LoadModelFromFile()

static AssetLoaderContext TriLibCore.AssetLoader.LoadModelFromFile ( string  path,
Action< AssetLoaderContext onLoad = null,
Action< AssetLoaderContext onMaterialsLoad = null,
Action< AssetLoaderContext, float >  onProgress = null,
Action< IContextualizedError onError = null,
GameObject  wrapperGameObject = null,
AssetLoaderOptions  assetLoaderOptions = null,
object  customContextData = null,
bool  haltTask = false,
Action< AssetLoaderContext onPreLoad = null,
bool  isZipFile = false 
)
static

Loads a Model from the given path asynchronously.

Parameters
pathThe Model file path.
onLoadThe Method to call on the Main Thread when the Model is loaded but resources may still pending.
onMaterialsLoadThe Method to call on the Main Thread when the Model and resources are loaded.
onProgressThe Method to call when the Model loading progress changes.
onErrorThe Method to call on the Main Thread when any error occurs.
wrapperGameObjectThe Game Object that will be the parent of the loaded Game Object. Can be null.
assetLoaderOptionsThe options to use when loading the Model.
customContextDataThe Custom Data that will be passed along the Context.
haltTaskTurn on this field to avoid loading the model immediately and chain the Tasks.
onPreLoadThe method to call on the parallel Thread before the Unity objects are created.
isZipFileIndicates whether to load from a Zip file.
Returns
The Asset Loader Context, containing Model loading information and the output Game Object.

◆ LoadModelFromFileNoThread()

static AssetLoaderContext TriLibCore.AssetLoader.LoadModelFromFileNoThread ( string  path,
Action< IContextualizedError onError = null,
GameObject  wrapperGameObject = null,
AssetLoaderOptions  assetLoaderOptions = null,
object  customContextData = null,
bool  isZipFile = false 
)
static

Loads a Model from the given path synchronously.

Parameters
pathThe Model file path.
onErrorThe Method to call on the Main Thread when any error occurs.
wrapperGameObjectThe Game Object that will be the parent of the loaded Game Object. Can be null.
assetLoaderOptionsThe options to use when loading the Model.
customContextDataThe Custom Data that will be passed along the Context.
isZipFileIndicates whether to load from a Zip file.
Returns
The Asset Loader Context, containing Model loading information and the output Game Object.

◆ LoadModelFromStream()

static AssetLoaderContext TriLibCore.AssetLoader.LoadModelFromStream ( Stream  stream,
string  filename = null,
string  fileExtension = null,
Action< AssetLoaderContext onLoad = null,
Action< AssetLoaderContext onMaterialsLoad = null,
Action< AssetLoaderContext, float >  onProgress = null,
Action< IContextualizedError onError = null,
GameObject  wrapperGameObject = null,
AssetLoaderOptions  assetLoaderOptions = null,
object  customContextData = null,
bool  haltTask = false,
Action< AssetLoaderContext onPreLoad = null,
bool  isZipFile = false 
)
static

Loads a Model from the given Stream asynchronously.

Parameters
streamThe Stream containing the Model data.
filenameThe Model filename.
fileExtensionThe Model file extension. (Eg.: fbx)
onLoadThe Method to call on the Main Thread when the Model is loaded but resources may still pending.
onMaterialsLoadThe Method to call on the Main Thread when the Model and resources are loaded.
onProgressThe Method to call when the Model loading progress changes.
onErrorThe Method to call on the Main Thread when any error occurs.
wrapperGameObjectThe Game Object that will be the parent of the loaded Game Object. Can be null.
assetLoaderOptionsThe options to use when loading the Model.
customContextDataThe Custom Data that will be passed along the Context.
haltTaskTurn on this field to avoid loading the model immediately and chain the Tasks.
onPreLoadThe method to call on the parallel Thread before the Unity objects are created.
isZipFileIndicates whether to load from a Zip file.
Returns
The Asset Loader Context, containing Model loading information and the output Game Object.

◆ LoadModelFromStreamNoThread()

static AssetLoaderContext TriLibCore.AssetLoader.LoadModelFromStreamNoThread ( Stream  stream,
string  filename = null,
string  fileExtension = null,
Action< IContextualizedError onError = null,
GameObject  wrapperGameObject = null,
AssetLoaderOptions  assetLoaderOptions = null,
object  customContextData = null,
bool  isZipFile = false 
)
static

Loads a Model from the given Stream synchronously.

Parameters
streamThe Stream containing the Model data.
filenameThe Model filename.
fileExtensionThe Model file extension. (Eg.: fbx)
onErrorThe Method to call on the Main Thread when any error occurs.
wrapperGameObjectThe Game Object that will be the parent of the loaded Game Object. Can be null.
assetLoaderOptionsThe options to use when loading the Model.
customContextDataThe Custom Data that will be passed along the Context.
isZipFileIndicates whether to load from a Zip file.
Returns
The Asset Loader Context, containing Model loading information and the output Game Object.

◆ LoadOrCreateScriptableObjectSafe()

static ScriptableObject TriLibCore.AssetLoader.LoadOrCreateScriptableObjectSafe ( string  typeName,
string  typeNamespace,
string  directory,
bool  instantiate 
)
static

Tries to load an ScriptableObject, or creates it with the given parameters if the ScriptableObject can't be found.

Parameters
typeNameThe ScriptableObject type name.
typeNamespaceThe ScriptableObject type namespace.
directoryThe directory where the ScriptableObject instance might be.
instantiateTurn on this field to instantiate the ScriptableObject.
Returns
The created ScriptableObject, or null.