Skip to content

Commit 367c5c8

Browse files
Fix transparency
1 parent 61cd4bd commit 367c5c8

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/SpriteLoader.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,11 +497,19 @@ private static void UICityRenderer_GetResource(ref GameObject __result, string b
497497

498498
public static Sprite BuildSprite(byte[] data, Vector2? pivot = null, float pixelsPerUnit = 2112f)
499499
{
500-
Texture2D texture = new(1, 1)
500+
Texture2D texture = new(1, 1, TextureFormat.RGBA32, false)
501501
{
502-
filterMode = FilterMode.Trilinear
502+
filterMode = FilterMode.Trilinear,
503503
};
504504
texture.LoadImage(data);
505+
Color[] pixels = texture.GetPixels();
506+
for (int i = 0; i < pixels.Length; i++)
507+
{
508+
if (Mathf.Approximately(pixels[i].a, 0))
509+
pixels[i] = new Color();
510+
}
511+
texture.SetPixels(pixels);
512+
texture.Apply();
505513
return Sprite.Create(
506514
texture,
507515
new(0, 0, texture.width, texture.height),

0 commit comments

Comments
 (0)