Forum rules - please read before posting.

Diffuse Sprite shader making sprites black

Hey all,

Just wanted to share this because I lost a bit of time on it. I was playing around with Unity's Sprites/Diffuse shader and noticed it was always showing black on my background sprites, but not on my player sprites. It turns out this is because I was using the "Align To Camera" script on the object I applied the shader to, which sets the Z scale of the GameObject to 0. When the Z scale is 0 the shader does not work properly and comes out black. I made a local fix In the Align method of AlignToCamera to make sure the Z value is always 1 and it fixed the problem.

If anyone is interested, this change I made is around line 114 in the file:
...
if (lockScale)
{
CalculateScale ();

if (scaleFactor != Vector2.zero)
{
                                Vector2 scale2D = scaleFactor * distanceToCamera;
                                transform.localScale = new Vector3(scale2D.x, scale2D.y, 1);
}
}
...
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.