How to create a transparent 2d mesh

Hi, I’m pretty new to Unity and I was trying to create a 2d mesh with script that is a single transparent color. I can’t figure out what kind of material I would need to use for it to work. I’ve tried the standard material and set it to the transparent setting, but it has some kind of gradient that changes on the angle you are looking at it? I’ve tried using the unlit colors material but the transparency effect doesn’t happen for some reason. Does anyone have an idea how I could fix the issue?

Here are some pictures of my code and what is happening:

Code:

Apparently, I can’t add all my images in a post because I’m a new member so I just add them below.

Standard Material

Unlit Materials

Everything you need to test about materials in your case can be tested with a few basic Unity Quad primitives, eg, right-click → 3D Object → Quad, then drag the materials you want on.

Anytime you have two pieces of geometry close enough to being coplanar you run the risk of Z-fighting.

There are techniques to avoid this, such as multiple cameras, custom shaders with multiple passes, etc.

Hi, thank you for responding.

So I tested the standard transparent material with the quad object and it works perfectly fine but my mesh isn’t transparent when I try creating it through script. Do you know why a mesh created in the way I’ve done wouldn’t be transparent but a Unity quad would?

Sorry, I just realized that I said something incorrect. My mesh is transparent but the coloring is weird. Why would creating a mesh in the way I’ve done make the color of the mesh act strange compared to Unity’s Quad?

The only thing that comes to mind would be not setting up the normals or bounds.

I always just have Unity do it for me… see lines 97 / 98:

That repo has a ton of random mesh procgen examples if you wanna goof around with it.

MakeGeo is presently hosted at these locations:

https://bitbucket.org/kurtdekker/makegeo

1 Like