public Task <Texture2DInfo> LoadTextureAsync(string texturePath) { var filePath = FindTexture(texturePath); if (filePath != null) { var fileData = MorrowindBSAFile.LoadFileData(filePath); return(Task.Run(() => { var fileExtension = Path.GetExtension(filePath); if (fileExtension?.ToLower() == ".dds") { return DDS.DDSReader.LoadDDSTexture(new MemoryStream(fileData)); } else { throw new NotSupportedException($"Unsupported texture type: {fileExtension}"); } })); } else { Debug.LogWarning("Could not find file \"" + texturePath + "\" in a BSA file."); return(Task.FromResult <Texture2DInfo>(null)); } }
public Texture2DInfo LoadTexture(string texturePath) { var filePath = FindTexture(texturePath); if (filePath != null) { var fileData = MorrowindBSAFile.LoadFileData(filePath); return(DDS.DDSReader.LoadDDSTexture(new MemoryStream(fileData))); } else { throw new FileNotFoundException("Could not find file \"" + texturePath + "\" in a BSA file."); } }