Tanoda
TextureMapperSample.cs
Go to the documentation of this file.
1using System;
2using System.IO;
3using TriLibCore.Interfaces;
5using TriLibCore.Utils;
6using UnityEngine;
7
8namespace TriLibCore.Samples
9{
13 public class TextureMapperSample : TextureMapper
14 {
22 public override TextureLoadingContext Map(AssetLoaderContext assetLoaderContext, ITexture texture)
23 {
24 var finalPath = $"{assetLoaderContext.BasePath}/{FileUtils.GetFilename(texture.Filename)}";
25 if (File.Exists(finalPath))
26 {
27 var textureLoadingContext = new TextureLoadingContext
28 {
29 Context = assetLoaderContext,
30 Stream = File.OpenRead(finalPath),
31 Texture = texture
32 };
33 Debug.Log($"Found texture at: {finalPath}");
34 return textureLoadingContext;
35 }
36
37 throw new Exception($"Texture {texture.Filename} not found.");
38 }
39 }
40}
UnityEngine.Debug Debug
Definition: TanodaServer.cs:19
Represents a class that finds textures at the given model base path.
override TextureLoadingContext Map(AssetLoaderContext assetLoaderContext, ITexture texture)
Tries to retrieve a Stream to the Texture native data based on the given context.