miuu-custom-cosmetic-loader/Shared.cs

55 lines
1.2 KiB
C#
Raw Normal View History

2023-09-03 02:06:53 -04:00
using System;
using UnityEngine;
namespace CustomCosmeticLoader
{
public static class Shared
{
private static Cosmetic skinToHijack;
public static Cosmetic SkinToHijack
{
get
{
if (skinToHijack == null)
{
DetermineSkinToHijack();
if (skinToHijack == null)
{
Debug.LogWarning("Couldn't find skin " + Config.skinNameToHijack + " to hijack");
Config.skinNameToHijack = "Swirl_M";
DetermineSkinToHijack();
}
2023-09-03 02:06:53 -04:00
}
return skinToHijack;
}
}
private static void DetermineSkinToHijack()
{
foreach (Cosmetic skin in CosmeticManager.Skins)
{
if (skin.Id == Config.skinNameToHijack)
{
skinToHijack = skin;
break;
}
}
}
public static void ApplyCustomTexture(GameObject marbleObject, Texture2D skin = null)
2023-09-03 02:06:53 -04:00
{
if (skin == null)
skin = Config.skins[Config.currentSkin];
2023-09-03 02:06:53 -04:00
MeshRenderer[] componentsInChildren = marbleObject.GetComponentsInChildren<MeshRenderer>();
for (int i = 0; i < componentsInChildren.Length; i++)
{
Material[] materials = componentsInChildren[i].materials;
foreach (Material material in materials)
material.mainTexture = skin;
2023-09-03 02:06:53 -04:00
}
}
}
}