#pragma warning disable 672 using System; using System.IO; using TriLibCore.Interfaces; using TriLibCore.Mappers; using TriLibCore.Utils; using UnityEngine; namespace TriLibCore.Samples { /// /// Represents a class that finds textures at the given model base path. /// public class TextureMapperSample : TextureMapper { /// Tries to retrieve a Stream to the Texture native data based on the given context. public override void Map(TextureLoadingContext textureLoadingContext) { var finalPath = $"{textureLoadingContext.Context.BasePath}/{FileUtils.GetFilename(textureLoadingContext.Texture.Filename)}"; if (File.Exists(finalPath)) { textureLoadingContext.Stream = File.OpenRead(finalPath); Debug.Log($"Found texture at: {finalPath}"); return; } throw new Exception($"Texture [{textureLoadingContext.Texture.Filename}] not found."); } } }