Files
Pal3.Unity/Assets/Scripts/Pal3.Game/Data/TextureProviderBase.cs
2024-04-25 02:50:11 -07:00

35 lines
1.0 KiB
C#

// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2024, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
namespace Pal3.Game.Data
{
using System;
using Core.FileSystem;
using Engine.Core.Abstraction;
public abstract class TextureProviderBase
{
protected ITexture2D GetTexture(IFileSystem fileSystem,
string texturePath,
ITextureLoader textureLoader,
out bool hasAlphaChannel)
{
byte[] data;
try
{
data = fileSystem.ReadAllBytes(texturePath);
}
catch (Exception)
{
hasAlphaChannel = false;
return null;
}
textureLoader.Load(data, out hasAlphaChannel);
return textureLoader.ToTexture();
}
}
}