-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBaseLoader.cs
More file actions
35 lines (28 loc) · 1.15 KB
/
BaseLoader.cs
File metadata and controls
35 lines (28 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System.IO;
using UnityEngine;
namespace Decal_Loader;
public abstract class BaseLoader(string configPath) {
protected readonly string configPath = configPath;
public void Init() {
if (!Directory.Exists(configPath)) return;
Load();
}
protected abstract void Load();
protected static DecalCategory CreateDecalCategory(string categoryName) {
var category = GameMod.CreateAndRegister<DecalCategory>(GUID.Create(), null); // GUID doesn't matter. Category is transient.
category.NameLocalization = new($"decals.category.{categoryName}", categoryName, ".");
LocalizationManager.Localize(category);
return category;
}
protected static void RegisterDecal(DecalCategory category, GUID guid, Texture2D texture) {
var decalResource = GameMod.CreateAndRegister<DecalResource>(guid, null);
decalResource.Resource = texture;
decalResource.Category = category;
}
protected static Texture2D LoadTexture(string file) {
var fileData = File.ReadAllBytes(file);
var tex = new Texture2D(1, 1);
tex.LoadImage(fileData);
return tex;
}
}