-
-
Save Seeker14491/d6b4d93ecc2ce38ed97b3265f4e50edd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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