2022-04-25 20:55:57 +00:00
|
|
|
|
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
|
|
|
|
|
{
|
2022-04-29 12:55:32 +00:00
|
|
|
|
public static Texture2D LoadTexture(string relativePath, TextureWrapMode wrapMode, bool forceMaxResolution)
|
2022-04-25 20:55:57 +00:00
|
|
|
|
{
|
|
|
|
|
var path = QSBCore.Helper.Manifest.ModFolderPath + relativePath;
|
|
|
|
|
|
|
|
|
|
if (!File.Exists(path))
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var data = File.ReadAllBytes(path);
|
2022-04-29 12:55:32 +00:00
|
|
|
|
var tex = forceMaxResolution
|
|
|
|
|
? new Texture2D(1, 1, TextureFormat.RGB24, false)
|
|
|
|
|
: new Texture2D(1, 1);
|
2022-04-25 20:55:57 +00:00
|
|
|
|
tex.LoadImage(data);
|
|
|
|
|
tex.wrapMode = wrapMode;
|
|
|
|
|
return tex;
|
|
|
|
|
}
|
|
|
|
|
}
|