Skip to content

Instantly share code, notes, and snippets.

@Seeker14491
Created July 2, 2018 00:19
Show Gist options
  • Save Seeker14491/d6b4d93ecc2ce38ed97b3265f4e50edd to your computer and use it in GitHub Desktop.
Save Seeker14491/d6b4d93ecc2ce38ed97b3265f4e50edd to your computer and use it in GitHub Desktop.
[HarmonyPatch(typeof(CarScreenLogic), "OnPlayerEventCarInstantiate")]
internal class Tmp2
{
static void Postfix(CarScreenLogic __instance)
{
var url = "https://i.imgur.com/jFR3Vat.jpg";
var newTexture = new Texture2D(1, 1);
using (WWW www = new WWW(url))
{
while (!www.isDone) {} // bad
www.LoadImageIntoTexture(newTexture);
}
Renderer[] componentsInChildren = Traverse.Create(__instance).Field("carTrans_").GetValue<Transform>().GetComponentsInChildren<Renderer>();
foreach (Renderer renderer in componentsInChildren)
{
Material[] materials = renderer.materials;
foreach (Material material in materials)
{
if (material.HasProperty("_CarScreenTex"))
{
material.SetTexture("_CarScreenTex", newTexture);
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment