This repository was archived by the owner on Jan 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSaveSystemPlugin.cs
More file actions
46 lines (36 loc) · 1.38 KB
/
SaveSystemPlugin.cs
File metadata and controls
46 lines (36 loc) · 1.38 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
36
37
38
39
40
41
42
43
44
45
46
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using BepInEx;
using HarmonyLib;
using UnityEngine;
namespace SaveUtility
{
[BepInPlugin("flarfo.saveutility","SaveUtility","0.1.0")]
public class SaveSystemPlugin : BaseUnityPlugin
{
private readonly Harmony harmony = new Harmony("SaveUtility");
public void Awake()
{
if (!Directory.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Saves")))
{
Directory.CreateDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Saves"));
}
Logger.LogInfo("Running Muck SaveUtility!");
var assetBundle = GetAssetBundleFromResource("saveutility");
UIManager.backgroundImage = assetBundle.LoadAsset<Texture>("Assets/Texture2D/groundCompressed.png");
harmony.PatchAll();
}
public static AssetBundle GetAssetBundleFromResource(string fileName)
{
var execAssembly = Assembly.GetExecutingAssembly();
var resourceName = execAssembly.GetManifestResourceNames().Single(str => str.EndsWith(fileName));
Debug.Log($"Resource Name: {resourceName}");
using (var stream = execAssembly.GetManifestResourceStream(resourceName))
{
return AssetBundle.LoadFromStream(stream);
}
}
}
}