mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2024-12-28 18:25:18 +00:00
31 lines
664 B
C#
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;
|
|
}
|
|
}
|