miuu-custom-cosmetic-loader/Patches/MarbleHolderPatches.cs

28 lines
768 B
C#
Raw Normal View History

2023-08-26 17:59:50 -04:00
using HarmonyLib;
using System;
using UnityEngine;
namespace CustomCosmeticLoader.Patches
{
2023-09-02 23:19:35 -04:00
[HarmonyPatch(typeof(MarbleHolder), nameof(MarbleHolder.SetMarble))]
2023-08-26 17:59:50 -04:00
internal class MarbleHolderSetMarblePatch
{
static void Postfix(MarbleHolder __instance, Cosmetic marbleObject)
{
if (!Config.enabled)
return;
if (marbleObject.Id != Config.skinToHijack && Config.skinToHijack != "*")
return;
2023-08-26 17:59:50 -04:00
MeshRenderer[] componentsInChildren = __instance.currentMarble.GetComponentsInChildren<MeshRenderer>();
for (int i = 0; i < componentsInChildren.Length; i++)
{
Material[] materials = componentsInChildren[i].materials;
foreach (Material material in materials)
material.mainTexture = Config.skins[Config.currentSkin];
2023-08-26 17:59:50 -04:00
}
}
}
}