miuu-custom-cosmetic-loader/Shared.cs

51 lines
1.1 KiB
C#

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();
}
}
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)
{
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 = Config.skins[Config.currentSkin];
}
}
}
}