quantum-space-buddies/QSB/Utility/TextureHelper.cs
Mister_Nebula 52c9533f9b stuff idk
2022-04-29 13:55:32 +01:00

31 lines
664 B
C#

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace QSB.Utility;
public static class TextureHelper
{
public static Texture2D LoadTexture(string relativePath, TextureWrapMode wrapMode, bool forceMaxResolution)
{
var path = QSBCore.Helper.Manifest.ModFolderPath + relativePath;
if (!File.Exists(path))
{
return null;
}
var data = File.ReadAllBytes(path);
var tex = forceMaxResolution
? new Texture2D(1, 1, TextureFormat.RGB24, false)
: new Texture2D(1, 1);
tex.LoadImage(data);
tex.wrapMode = wrapMode;
return tex;
}
}