TriLib 2.2.8
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Properties | List of all members
TriLibCore.AssetLoaderContext Class Reference

Represents the main context containing Model loading data. More...

Inheritance diagram for TriLibCore.AssetLoaderContext:
TriLibCore.Interfaces.IAssetLoaderContext TriLibCore.Interfaces.IAwaitable

Public Member Functions

bool TryGetMaterialTexture (IMaterial material, TextureType textureType, out Texture loadedTexture)
 Tries to get a processed Texture from a given Material.
 
bool TryGetLoadedTexture (TextureLoadingContext textureLoadingContext, out TextureLoadingContext existingTextureLoadingContext)
 Tries to get a Texture from the loaded Textures list.
 
void AddUsedTexture (Texture texture)
 Adds the given Texture to the loaded Textures list.
 
void DiscardUnusedTextures ()
 Discards unused Textures and removes it from the allocations list.
 
void AddActionToQueue (IContextualizedAction contextualizedAction)
 Adds the given Action to the List of Actions to be executed on the main Thread.
 
void ExecuteActionsQueue (Action< AssetLoaderContext > onFinish)
 Executes the actions queue in the main Thread.
 
byte[] GetBufferFromPool (int length)
 Returns a byte array from the internal pool.
 

Public Attributes

readonly List< Object > Allocations = new List<Object>()
 Unity object allocations list.
 
readonly Dictionary< GameObject, string > GameObjectPaths = new Dictionary<GameObject, string>()
 Mapping between created Game Objects and their hierarchy path.
 
readonly Dictionary< IModel, GameObject > GameObjects = new Dictionary<IModel, GameObject>()
 Mapping between Models representations and created Game Objects.
 
readonly ConcurrentDictionary< IMaterial, Material > GeneratedMaterials = new ConcurrentDictionary<IMaterial, Material>()
 Mapping between Material representations and Unity Materials generated on-the-fly.
 
readonly ConcurrentDictionary< string, string > LoadedExternalData = new ConcurrentDictionary<string, string>()
 Mapping between short external resource filenames and their complete filenames.
 
readonly ConcurrentDictionary< IMaterial, Material > LoadedMaterials = new ConcurrentDictionary<IMaterial, Material>()
 Mapping between Material representations and created Unity Materials.
 
readonly ConcurrentDictionary< ITexture, TextureLoadingContextLoadedTextures = new ConcurrentDictionary<ITexture, TextureLoadingContext>()
 Mapping between Texture representations and Texture Loading Contexts.
 
readonly ConcurrentDictionary< IMaterial, List< MaterialRendererContext > > MaterialRenderers = new ConcurrentDictionary<IMaterial, List<MaterialRendererContext>>()
 Mapping between Material representations and Material Renderer Contexts.
 
readonly ConcurrentDictionary< CompoundMaterialKey, TextureLoadingContextMaterialTextures = new ConcurrentDictionary<CompoundMaterialKey, TextureLoadingContext>()
 Mapping between Materials Textures and Unity Textures.
 
readonly Dictionary< GameObject, IModelModels = new Dictionary<GameObject, IModel>()
 Mapping between created Game Objects and raw Models.
 
bool AppliedDoubleSidedMaterials
 Indicates whether double sided materials have been applied to the last processed mesh.
 
bool Async = true
 Indicates whether the context Model is being loaded asynchronously.
 
string BasePath
 The Base path from where the Model is loaded.
 
CancellationToken CancellationToken
 Reference to the Cancellation Token used to limit the duration of the requests.
 
CancellationTokenSource CancellationTokenSource
 The CancellationTokenSource can be used to cancel a model loading on demand.
 
object CustomData
 Reference to any custom data to pass to the context.
 
string FileExtension
 The Model extension when loading from a stream.
 
string Filename
 The Model filename when loading from the local file system.
 
bool HaltTasks
 Indicates whether tasks should be initialized immediately.
 
Action< IContextualizedErrorHandleError
 Reference to the Asset Loader error handling event, which does additional handling before calling OnError.
 
bool IsZipFile
 This flag indicates whether the model is loaded from a Zip file.
 
float LoadingProgress
 Indicates the model loading progress.
 
string ModificationDate
 Stores the format-specific file modification date.
 
Action< IContextualizedErrorOnError
 Reference to the error event.
 
Action< AssetLoaderContextOnLoad
 Reference to the load event, triggered when the Model has loaded, but resources may still pending.
 
Action< AssetLoaderContextOnMaterialsLoad
 Reference to the materials load event, triggered when the Model and resources have loaded.
 
Action< AssetLoaderContextOnPreLoad
 The method to call on the parallel Thread before the Unity objects are created.
 
Action< AssetLoaderContext, float > OnProgress
 Reference to the Model loading progress updating event.
 
AssetLoaderOptions Options
 Reference to the Options used to load the Model.
 
ReaderBase Reader
 Reference to the Reader used to load the Model.
 
GameObject RootGameObject
 Reference to the loaded root Game Object.
 
IRootModel RootModel
 Reference to the Loaded Model representation.
 
Stream Stream
 Stream used to load the Model when not loading from the local file system.
 
Task Task
 The Task created for this Context.
 
List< TaskTasks = new List<Task>()
 Reference to the tasks used when loading the Model Asynchronously.
 
GameObject WrapperGameObject
 Reference to the Game Object to be the parent of the loaded Model.
 

Properties

string PersistentDataPath [get, set]
 Stores the Application Persistent Data Path.
 
bool Completed [get, set]
 Indicates whether this Awaitable is completed.
 
- Properties inherited from TriLibCore.Interfaces.IAssetLoaderContext
AssetLoaderContext Context [get]
 Gets/Sets the Asset Loader Context reference. Asset Loader Context contains the Model loading data.
 
- Properties inherited from TriLibCore.Interfaces.IAwaitable
bool Completed [get, set]
 Indicates whether this Awaitable is completed.
 

Detailed Description

Represents the main context containing Model loading data.

Member Function Documentation

◆ AddActionToQueue()

void TriLibCore.AssetLoaderContext.AddActionToQueue ( IContextualizedAction  contextualizedAction)

Adds the given Action to the List of Actions to be executed on the main Thread.

Parameters
contextualizedActionThe Action to add to the List.

◆ AddUsedTexture()

void TriLibCore.AssetLoaderContext.AddUsedTexture ( Texture  texture)

Adds the given Texture to the loaded Textures list.

Parameters
textureThe Texture to add to the list.

◆ ExecuteActionsQueue()

void TriLibCore.AssetLoaderContext.ExecuteActionsQueue ( Action< AssetLoaderContext onFinish)

Executes the actions queue in the main Thread.

Parameters
onFinishThe action to be executed when the actions queue is finished.

◆ GetBufferFromPool()

byte[] TriLibCore.AssetLoaderContext.GetBufferFromPool ( int  length)

Returns a byte array from the internal pool.

Parameters
lengthThe byte array length.
Returns
The byte array from the internal pool.

◆ TryGetLoadedTexture()

bool TriLibCore.AssetLoaderContext.TryGetLoadedTexture ( TextureLoadingContext  textureLoadingContext,
out TextureLoadingContext  existingTextureLoadingContext 
)

Tries to get a Texture from the loaded Textures list.

Parameters
textureLoadingContextThe TextureLoadingContext containing the Texture to lookup for.
existingTextureLoadingContextThe TextureLoadingContext used to load the Texture, if found.
Returns
true if the Texture was found on the loaded Textures list. Otherwise, false.

◆ TryGetMaterialTexture()

bool TriLibCore.AssetLoaderContext.TryGetMaterialTexture ( IMaterial  material,
TextureType  textureType,
out Texture  loadedTexture 
)

Tries to get a processed Texture from a given Material.

Parameters
materialOriginal Material.
textureTypeThe Texture type to search for.
loadedTextureThe found Texture, or null.
Returns
true if the Texture is found, otherwise false.

Property Documentation

◆ Completed

bool TriLibCore.AssetLoaderContext.Completed
getset

Indicates whether this Awaitable is completed.

Implements TriLibCore.Interfaces.IAwaitable.