Skip to content

Commit 9830603

Browse files
committed
Fixed tech tree stuff disappearing
1 parent 15adffb commit 9830603

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

src/Managers/Visual.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,26 @@ private static void StartScreen_Start()
5151
firstTimeOpeningPreview = true;
5252
}
5353

54-
[HarmonyPostfix]
54+
[HarmonyPrefix]
5555
[HarmonyPatch(typeof(SpriteAtlasManager), nameof(SpriteAtlasManager.LoadSprite), typeof(string), typeof(string), typeof(SpriteCallback))] // temporary fix
56-
private static void SpriteAtlasManager_LoadSprite_Postfix(SpriteAtlasManager __instance, string atlas, string sprite, SpriteCallback completion)
56+
private static bool SpriteAtlasManager_LoadSprite_Postfix(SpriteAtlasManager __instance, string atlas, string sprite, SpriteCallback completion)
5757
{
58+
bool found = false;
5859
__instance.LoadSpriteAtlas(atlas, (Il2CppSystem.Action<UnityEngine.U2D.SpriteAtlas>)GetAtlas);
60+
61+
return !found;
62+
5963
void GetAtlas(SpriteAtlas spriteAtlas)
6064
{
6165
if (spriteAtlas != null)
6266
{
63-
completion?.Invoke(atlas, sprite, __instance.GetSpriteFromAtlas(spriteAtlas, sprite));
64-
return;
67+
Sprite foundSprite = __instance.GetSpriteFromAtlas(spriteAtlas, sprite);
68+
if(foundSprite != null)
69+
{
70+
completion?.Invoke(atlas, sprite, __instance.GetSpriteFromAtlas(spriteAtlas, sprite));
71+
found = true;
72+
}
6573
}
66-
completion?.Invoke(atlas, sprite, null);
6774
}
6875
}
6976

0 commit comments

Comments
 (0)