Setting disc color from a variable or changing source does not render a disc

Avatar
  • updated
  • Not a bug

Inheriting ImmediateModeShapeDrawer in a custom script, I've found that setting the Disc color (probably other shapes, but have only tested with Disc) from a variable results in nothing rendering.

To test, in the DrawShapes(Camera cam) function:

Draw.Disc(Vector3.zero, 100, Color.red);

works! A red disc shows up. However, replacing Color.red in the same instance with:

Draw.Disc(Vector3.zero, 100, colorList[Random.Range(0, colorList.Length)]);

doesn't work, no disc is rendered. colorArray is an array of colors that does have elements and does not change size/values during runtime, so a randomly colored disc should appear every frame.

Likewise, trying to use colors from changing sources (eg if there's a Light 'lightComp' that changes color every frame, using lightComp.color for the disc color) does not work and nothing is rendered. If the lightComp.color does not change it is fine. This extends to DiscGradientRadial (where I first found this issue).

The same issue exists if you create a Disc in-scene and reference it (tested in Start() and Update() separately).

Works:
Setting the color to a static color (Color.red) or a non-changing source (lightComp.color if light color does not get modified). Eg disc.color = Color.red;

Doesn't work:

Setting the color to a variable value (random element from Color[] colorArray) or a changing source (lightComp.color if light color is being changed via script) Eg disc.color = lightComp.color; or disc.color = colorList[Random.Range(0, colorList.Length)];

Some additional fun: from a Disc created in scene and reference in script, in Update, having the outerColor be Color.red and changing the inner color to a random element of colorArray looks like this (in this frame purple was the inner color set)

Image 371

the dark-blue is a backdrop. So the disc is receiving the color change, but something about the rendering is off. If both inner and outerColor are set to a random color, nothing appears.

Reporting a bug? please specify Unity version:
2019.3.11f1
Reporting a bug? please specify Shapes version:
3.2.3
Reporting a bug? please specify Render Pipeline:
Built-in render pipeline
Avatar
Freya Holmér creator
  • Under Review

is the alpha of the colors in the array set to 0?

Avatar
Richard S

That absolutely was it. I feel like an idiot. Sorry for wasting your time, great asset btw

Avatar
Freya Holmér creator
  • Not a bug

no worries~ it happens