AsImpL 1.0
Asynchronous Importer and run-time Loader for Unity
AsImpL.Loader Class Referenceabstract

Abstract loader to be used as a base class for specific loaders. More...

Inheritance diagram for AsImpL.Loader:
AsImpL.LoaderObj

Classes

struct  BuildStats
 
struct  Stats
 

Public Member Functions

IEnumerator Load (string objName, string absolutePath, Transform parentObj)
 Load a model. More...
 
abstract string[] ParseTexturePaths (string absolutePath)
 Parse the model to get a list of the paths of all used textures More...
 

Static Public Member Functions

static GameObject GetModelByPath (string absolutePath)
 Get a previusly loaded model by its absolute path More...
 

Public Attributes

ImportOptions buildOptions
 Options to define how the model will be loaded and imported. More...
 

Static Public Attributes

static LoadingProgress totalProgress = new LoadingProgress()
 Total loading progress, for all the models currently loading. More...
 

Protected Member Functions

abstract IEnumerator LoadModelFile (string absolutePath)
 Load the main model file More...
 
abstract IEnumerator LoadMaterialLibrary (string absolutePath)
 Load the material library from the given path. More...
 
IEnumerator Build (string absolutePath, string objName, Transform parentTransform)
 Build the game objects from data set, materials and textures. More...
 
string GetDirName (string absolutePath)
 Get the directory name of the given path, appending the final slash if eeded. More...
 
virtual void OnLoaded (GameObject obj, string absolutePath)
 
virtual void OnCreated (GameObject obj, string absolutePath)
 
virtual void OnLoadFailed (string absolutePath)
 

Protected Attributes

DataSet dataSet = new DataSet()
 
ObjectBuilder objectBuilder = null
 
List< MaterialDatamaterialData
 
SingleLoadingProgress objLoadingProgress = new SingleLoadingProgress()
 
Stats loadStats
 

Static Protected Attributes

static float LOAD_PHASE_PERC = 8f
 
static float TEXTURE_PHASE_PERC = 1f
 
static float MATERIAL_PHASE_PERC = 1f
 
static float BUILD_PHASE_PERC = 90f
 
static Dictionary< string, GameObject > loadedModels = new Dictionary<string, GameObject>()
 
static Dictionary< string, int > instanceCount = new Dictionary<string, int>()
 

Properties

ObjectBuilder?? ObjectBuilder [getset]
 Warning! This will be removed soon to avoid confusion between the ObjectBuilder class and this property, use Builder property instead. More...
 
ObjectBuilder?? Builder [getset]
 Object used to build the game object hierarchy (it is created if not previously set). More...
 
bool? ConvertVertAxis [getset]
 Load the file assuming its vertical axis is Z instead of Y More...
 
float? Scaling [getset]
 Rescaling for the model (1 = no rescaling) More...
 
IFilesystem Filesystem [getset]
 
abstract bool HasMaterialLibrary [get]
 Check if a material library is defined for this model More...
 

Events

Action< GameObject, string > ModelCreated
 Event triggered when an object is created. More...
 
Action< GameObject, string > ModelLoaded
 Event triggered when an object is successfully loaded. More...
 
Action< string > ModelError
 Event triggered if failed to load an object More...
 

Detailed Description

Abstract loader to be used as a base class for specific loaders.

Member Function Documentation

◆ Build()

IEnumerator AsImpL.Loader.Build ( string  absolutePath,
string  objName,
Transform  parentTransform 
)
protected

Build the game objects from data set, materials and textures.

Parameters
absolutePathabsolute file path
objNameName of the main game object (model root)
parentTransformtransform to which the model root will be attached (if null it will be a root aobject)

This is called by Load() method

◆ GetDirName()

string AsImpL.Loader.GetDirName ( string  absolutePath)
protected

Get the directory name of the given path, appending the final slash if eeded.

Parameters
absolutePaththe absolute path
Returns
the directory name ending with /

◆ GetModelByPath()

static GameObject AsImpL.Loader.GetModelByPath ( string  absolutePath)
static

Get a previusly loaded model by its absolute path

Parameters
absolutePathabsolute path used to load the model
Returns
The game object previously loaded

◆ Load()

IEnumerator AsImpL.Loader.Load ( string  objName,
string  absolutePath,
Transform  parentObj 
)

Load a model.

Parameters
objNamename of the GameObject, if empty use file name
absolutePathabsolute file path
parentObjTransform to which attach the loaded object (null=scene)
Returns
You can use StartCoroutine( loader.Load(...) )

◆ LoadMaterialLibrary()

abstract IEnumerator AsImpL.Loader.LoadMaterialLibrary ( string  absolutePath)
protectedpure virtual

Load the material library from the given path.

Parameters
absolutePathabsolute file path

This is called by Load() method

Implemented in AsImpL.LoaderObj.

◆ LoadModelFile()

abstract IEnumerator AsImpL.Loader.LoadModelFile ( string  absolutePath)
protectedpure virtual

Load the main model file

Parameters
absolutePathabsolute file path

This is called by Load() method

Implemented in AsImpL.LoaderObj.

◆ OnCreated()

virtual void AsImpL.Loader.OnCreated ( GameObject  obj,
string  absolutePath 
)
protectedvirtual

◆ OnLoaded()

virtual void AsImpL.Loader.OnLoaded ( GameObject  obj,
string  absolutePath 
)
protectedvirtual

◆ OnLoadFailed()

virtual void AsImpL.Loader.OnLoadFailed ( string  absolutePath)
protectedvirtual

◆ ParseTexturePaths()

abstract string[] AsImpL.Loader.ParseTexturePaths ( string  absolutePath)
pure virtual

Parse the model to get a list of the paths of all used textures

Parameters
absolutePathabsolute path of the model
Returns
List of paths of the textures referenced by the model

Implemented in AsImpL.LoaderObj.

Member Data Documentation

◆ BUILD_PHASE_PERC

float AsImpL.Loader.BUILD_PHASE_PERC = 90f
staticprotected

◆ buildOptions

ImportOptions AsImpL.Loader.buildOptions

Options to define how the model will be loaded and imported.

◆ dataSet

DataSet AsImpL.Loader.dataSet = new DataSet()
protected

◆ instanceCount

Dictionary<string, int> AsImpL.Loader.instanceCount = new Dictionary<string, int>()
staticprotected

◆ LOAD_PHASE_PERC

float AsImpL.Loader.LOAD_PHASE_PERC = 8f
staticprotected

◆ loadedModels

Dictionary<string, GameObject> AsImpL.Loader.loadedModels = new Dictionary<string, GameObject>()
staticprotected

◆ loadStats

Stats AsImpL.Loader.loadStats
protected

◆ MATERIAL_PHASE_PERC

float AsImpL.Loader.MATERIAL_PHASE_PERC = 1f
staticprotected

◆ materialData

List<MaterialData> AsImpL.Loader.materialData
protected

◆ objectBuilder

ObjectBuilder AsImpL.Loader.objectBuilder = null
protected

◆ objLoadingProgress

SingleLoadingProgress AsImpL.Loader.objLoadingProgress = new SingleLoadingProgress()
protected

◆ TEXTURE_PHASE_PERC

float AsImpL.Loader.TEXTURE_PHASE_PERC = 1f
staticprotected

◆ totalProgress

LoadingProgress AsImpL.Loader.totalProgress = new LoadingProgress()
static

Total loading progress, for all the models currently loading.

Property Documentation

◆ Builder

ObjectBuilder?? AsImpL.Loader.Builder
getset

Object used to build the game object hierarchy (it is created if not previously set).

◆ ConvertVertAxis

bool? AsImpL.Loader.ConvertVertAxis
getset

Load the file assuming its vertical axis is Z instead of Y

◆ Filesystem

IFilesystem AsImpL.Loader.Filesystem
getset

◆ HasMaterialLibrary

abstract bool AsImpL.Loader.HasMaterialLibrary
getprotected

Check if a material library is defined for this model

◆ ObjectBuilder

ObjectBuilder?? AsImpL.Loader.ObjectBuilder
getset

Warning! This will be removed soon to avoid confusion between the ObjectBuilder class and this property, use Builder property instead.

◆ Scaling

float? AsImpL.Loader.Scaling
getset

Rescaling for the model (1 = no rescaling)

Event Documentation

◆ ModelCreated

Action<GameObject, string> AsImpL.Loader.ModelCreated

Event triggered when an object is created.

◆ ModelError

Action<string> AsImpL.Loader.ModelError

Event triggered if failed to load an object

◆ ModelLoaded

Action<GameObject, string> AsImpL.Loader.ModelLoaded

Event triggered when an object is successfully loaded.


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