Skip to content

Commit

Permalink
Mostly fixed UI rendering on top
Browse files Browse the repository at this point in the history
  • Loading branch information
Raicuparta committed Feb 8, 2022
1 parent 949d58b commit e4a26be
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions TwoForksVr/src/UI/Patches/UIPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,27 @@ private static void PreventTextFromDrawingOnTop(TextMeshProUGUI __instance)
{
try
{
if (__instance.canvas && !__instance.canvas.GetComponent<GraphicRaycaster>()) return;
var isInteractive = __instance.canvas && __instance.canvas.GetComponent<GraphicRaycaster>();
var key = $"{__instance.font.name}{(isInteractive ? "interactive" : "non-interactive")}";

var key = __instance.font.name;
materialMap.TryGetValue(key, out var material);

if (!materialMap.ContainsKey(key))
materialMap[key] = new Material(__instance.font.material)
{
shader = VrAssetLoader.TMProShader
};
if (material == null)
{
material = new Material(__instance.font.material);
if (__instance.canvas && __instance.canvas.GetComponent<GraphicRaycaster>())
material.shader = VrAssetLoader.TMProShader;

var material = materialMap[key];
__instance.fontMaterial = material;
__instance.fontBaseMaterial = material;
materialMap[key] = material;
}

__instance.SetFontMaterial(material);
__instance.SetSharedFontMaterial(material);
__instance.SetFontBaseMaterial(material);

// Problem: setting fontSharedMaterial is needed to prevent errors and the empty settings dropdowns,
// but it also makes the dialog choices stop rendering on top.
__instance.fontSharedMaterial = material;
// __instance.fontSharedMaterial = material;
}
catch (Exception exception)
{
Expand Down

0 comments on commit e4a26be

Please sign in to comment.