This repository has been archived by the owner on Apr 6, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
ResourceManager.cs
52 lines (47 loc) · 1.91 KB
/
ResourceManager.cs
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
47
48
49
50
51
52
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnhollowerRuntimeLib;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.UI;
using MelonLoader;
using System.Collections;
using System.IO;
using System.Reflection;
namespace ActiveBackground
{
class ResourceManager
{
private static AssetBundle Bundle;
public static Material BlurGoBrrr, BlurLite;
private static Material LoadMateral(string assetToLoad)
{
Material loadedMaterial = Bundle.LoadAsset_Internal(assetToLoad, Il2CppType.Of<Material>()).Cast<Material>();
loadedMaterial.hideFlags |= HideFlags.DontUnloadUnusedAsset;
return loadedMaterial;
}
public static void Init() { MelonCoroutines.Start(LoadResources()); }
private static IEnumerator LoadResources()
{
// Came from UIExpansionKit (https://github.com/knah/VRCMods/blob/master/UIExpansionKit)
MelonLogger.Msg("Loading AssetBundle...");
using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("ActiveBackground.activebackground.ab"))
{
using (var memoryStream = new MemoryStream((int)stream.Length))
{
stream.CopyTo(memoryStream);
Bundle = AssetBundle.LoadFromMemory_Internal(memoryStream.ToArray(), 0);
Bundle.hideFlags |= HideFlags.DontUnloadUnusedAsset;
try { BlurGoBrrr = LoadMateral("BlurGoBrr.mat"); } catch { MelonLogger.Error("Custom Material failed"); }
try { BlurLite = LoadMateral("Blur Lite.mat"); } catch { MelonLogger.Error("Alt Custom Material failed"); }
}
}
if (Main.isDebug)
MelonLogger.Msg("Finihsed with Asset Bundle Resource Managment");
yield break;
}
}
}