add TextureHelper

This commit is contained in:
Mister_Nebula 2022-04-25 21:55:57 +01:00
parent 71419836ef
commit e743e42537
2 changed files with 31 additions and 6 deletions

View File

@ -68,12 +68,9 @@ internal class QSBPrisonCellElevator : WorldObject<PrisonCellElevator>, IQSBDrop
var projectorComponent = AUTO_SLIDE_PROJECTOR.AddComponent<CustomAutoSlideProjector>();
projectorComponent._light = Light.GetComponent<OWLight2>();
var cellevator1 = QSBCore.Helper.Assets.GetTexture("Assets/cellevator1.png");
cellevator1.wrapMode = TextureWrapMode.Clamp;
var cellevator2 = QSBCore.Helper.Assets.GetTexture("Assets/cellevator2.png");
cellevator2.wrapMode = TextureWrapMode.Clamp;
var cellevator3 = QSBCore.Helper.Assets.GetTexture("Assets/cellevator3.png");
cellevator3.wrapMode = TextureWrapMode.Clamp;
var cellevator1 = TextureHelper.LoadTexture("Assets/cellevator1.png", TextureWrapMode.Clamp);
var cellevator2 = TextureHelper.LoadTexture("Assets/cellevator2.png", TextureWrapMode.Clamp);
var cellevator3 = TextureHelper.LoadTexture("Assets/cellevator3.png", TextureWrapMode.Clamp);
var slideCollection = new CustomSlideCollection(3);
slideCollection.slides[0] = new CustomSlide() { _image = cellevator1 };

View File

@ -0,0 +1,28 @@
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)
{
var path = QSBCore.Helper.Manifest.ModFolderPath + relativePath;
if (!File.Exists(path))
{
return null;
}
var data = File.ReadAllBytes(path);
var tex = new Texture2D(1, 1);
tex.LoadImage(data);
tex.wrapMode = wrapMode;
return tex;
}
}