Files
Pal3.Unity/Assets/Scripts/Pal3/Data/TextureProviderBase.cs
T
Jiaqi Liu 73bcaa2cbf Code refactoring
Code refactoring
2022-03-27 16:19:15 -07:00

31 lines
1.0 KiB
C#

// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2022, Jiaqi Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
namespace Pal3.Data
{
using Core.DataLoader;
using Core.FileSystem;
using UnityEngine;
public abstract class TextureProviderBase
{
protected Texture2D GetTexture(ICpkFileSystem fileSystem,
string texturePath,
ITextureLoader textureLoader,
out bool hasAlphaChannel)
{
// Just to make sure we have the texture
if (!fileSystem.FileExists(texturePath))
{
hasAlphaChannel = false;
return null;
}
var data = fileSystem.ReadAllBytes(texturePath);
textureLoader.Load(data, out hasAlphaChannel);
return textureLoader.ToTexture2D();
}
}
}