Skip to content

Commit

Permalink
Added patch to speed up color getter on Material.
Browse files Browse the repository at this point in the history
  • Loading branch information
CptMoore committed Jan 10, 2025
1 parent b5ae16a commit 56f83a8
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions RogueTechPerfFixes/Patches/Material_get_color_Patch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using UnityEngine;

namespace RogueTechPerfFixes.Patches;

[HarmonyPatch(typeof(Material), nameof(Material.color), MethodType.Getter)]
internal static class Material_get_color_Patch
{
private static int s_id;
public static void Prepare()
{
s_id = Shader.PropertyToID("_Color");
}

public static void Prefix(Material __instance, ref bool __runOriginal, ref Color __result)
{
__result = __instance.GetColor(s_id);
__runOriginal = false;
}
}

0 comments on commit 56f83a8

Please sign in to comment.