Possible Bug UI.RawImage Android

Morning,

I’m trying to show a damage bar in my game using UI.RawImage with a RenderTexture and a custom shader.
It works perfectly in the editor but fails on an android build.

Here’s a video of in on android:

It’s the blue box that’s broken.

It also works on Android if I remove the shader. Here’s the shader:

{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
LOD 100

Blend SrcAlpha OneMinusSrcAlpha

Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag

#include "UnityCG.cginc"

struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};

struct v2f
{
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
};

sampler2D _MainTex;
float4 _MainTex_ST;

v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
return o;
}

fixed4 frag (v2f i) : SV_Target
{
// sample the texture
fixed4 col = tex2D(_MainTex, i.uv);
//reverse alpha

col.b=col.a = 1 - col.r;
col.r=col.g = 0.3;

return col;
}
ENDCG
}
}
}```

Not exactly complicated.

Can anyone see anything wrong?

Given the fact that it works perfectly in the editor should I file a bug report?

I think you should ask in Unity Engine - Unity Discussions

Would that be the correct place? Is it an issue with TMPro? I thought RawImage was part of the UI package.

It’s the Unity UI & TextMesh Pro forums. Thread was in UI Toolkit forums, which is different.

Ok. Thanks. I see it’s already been moved so thanks for that as well.

1 Like