How to track loaded resources: mudanças entre as edições

De TriLib
Ir para navegação Ir para pesquisar
(Criou página com 'On your "MaterialsLoadedCallback", you can use the following snippet to track the loaded resources, in case you need to copy/move them elsewhere: <source lang="csharp"> foreac...')
 
Sem resumo de edição
 
(10 revisões intermediárias pelo mesmo usuário não estão sendo mostradas)
Linha 1: Linha 1:
On your "MaterialsLoadedCallback", you can use the following snippet to track the loaded resources, in case you need to copy/move them elsewhere:
You can use the following snippet on your loading methods <code>'''onMaterialsLoad'''</code> callback to track the loaded resources if you need to copy/move them elsewhere:
<source lang="csharp">
<pre>
foreach (KeyValuePair<ITexture, TextureLoadingContext> kvp in assetLoaderContext.LoadedTextures)
//ModelPath contains the loaded model path
var modelPath = assetLoaderContext.Filename;
if (!string.IsNullOrEmpty(modelPath))
{
{
//Do stuff
}
//Iterate the loaded textures list
foreach (var kvp in assetLoaderContext.LoadedCompoundTextures)
{
//FinalPath contains the loaded texture filename
string finalPath = kvp.Key.ResolvedFilename;
string finalPath = kvp.Key.ResolvedFilename;
if (!string.IsNullOrEmpty(finalPath))
if (!string.IsNullOrEmpty(finalPath))
{
{
//Finalpath contains the loaded texture filename
//Do stuff
}
}
}
}
foreach (KeyValuePair<string, string> kvp in assetLoaderContext.LoadedExternalData)
 
//Iterate the loaded resources list
foreach (var kvp in assetLoaderContext.LoadedExternalData)
{
{
//FinalPath contains the loaded resource filename
string finalPath = kvp.Value;
string finalPath = kvp.Value;
if (!string.IsNullOrEmpty(finalPath))
if (!string.IsNullOrEmpty(finalPath))
{
{
//Finalpath contains the loaded resource filename
//Do stuff
}
}
}
}
</source>
</pre>

Edição atual tal como às 09h18min de 18 de maio de 2024

You can use the following snippet on your loading methods onMaterialsLoad callback to track the loaded resources if you need to copy/move them elsewhere:

//ModelPath contains the loaded model path
var modelPath = assetLoaderContext.Filename;
if (!string.IsNullOrEmpty(modelPath))
{
	//Do stuff
}

//Iterate the loaded textures list
foreach (var kvp in assetLoaderContext.LoadedCompoundTextures)
{
	//FinalPath contains the loaded texture filename
	string finalPath = kvp.Key.ResolvedFilename;
	if (!string.IsNullOrEmpty(finalPath))
	{
		//Do stuff
	}
}

//Iterate the loaded resources list
foreach (var kvp in assetLoaderContext.LoadedExternalData)
{
	//FinalPath contains the loaded resource filename
	string finalPath = kvp.Value;
	if (!string.IsNullOrEmpty(finalPath))
	{
		//Do stuff
	}
}