63 lines
1.4 KiB
C#
63 lines
1.4 KiB
C#
using System;
|
|
using UnityEngine;
|
|
|
|
namespace CustomCosmeticLoader
|
|
{
|
|
public static class Shared
|
|
{
|
|
private static Cosmetic skinToHijack;
|
|
|
|
public static Cosmetic SkinToHijack
|
|
{
|
|
get
|
|
{
|
|
if (skinToHijack != null && skinToHijack.Id != Config.skinNameToHijack)
|
|
skinToHijack = null;
|
|
|
|
if (skinToHijack == null)
|
|
{
|
|
DetermineSkinToHijack();
|
|
if (skinToHijack == null)
|
|
{
|
|
Shared.Log("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, Texture2D skin = null)
|
|
{
|
|
if (skin == null)
|
|
skin = Config.skins[Config.currentSkin];
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
public static void Log(string message)
|
|
{
|
|
message = "[CUSTOM COSMETIC LOADER] " + message;
|
|
Debug.Log(message);
|
|
}
|
|
}
|
|
}
|