Issues with changing alpha value of Polyline in Immediate Draw mode

Avatar
  • updated

While using DOTween to try and change the color and alpha of a polyline in script, I noticed an interesting issue. The tween allowed me to decrease the alpha of my line, but not increase it. If for instance I set the initial color of my polyline to clear, it will remain clear even after the tween executes. However, if I set the color to solid white with an alpha of 1, the alpha will decrease to the proper value. This remains true if I set the alpha to something like .1f, it will remain mostly translucent without ever increasing the alpha value.

Reporting a bug? please specify Unity version:
2021.3.37f1
Reporting a bug? please specify Shapes version:
4.3.1
Reporting a bug? please specify Render Pipeline:
URP
Avatar
Cameron Russo

I have an update to this - I tried doing it with just a normal game object as well and got the same issue. Seems like it's not just an immediate mode bug, I just seem to be unable to increase the alpha of an object during runtime

Avatar
Freya Holmér creator

hm, do you have sample code for how you're setting the color?

Avatar
Cameron Russo

Yeah for sure: 

private IEnumerator UpdateColors()
{
sq = DOTween.Sequence();
Debug.Log("Trail size: " + trail.Count);
yield return new WaitForSeconds(.5f);
for (int i = 0; i < trail.Count; ++i)
{
yield return DOTween.To(() => trail[i].color, x=>trail.SetColor(i, x), color, fadeInTime).WaitForCompletion();
}
//yield return sq.Play().WaitForCompletion();
}

Above is the code I was originally using to set the color in Immediate mode. Today while working on this a little further today, I came up with a solution that seems to be working despite it being weird. 

private void OnEnable()
{
pl = GetComponent<Polyline>();
for (int i = 0; i < starLocs.Count; i++)
{
Debug.Log(pl.Count);
pl.SetPointThickness(i, thickness);
pl.SetPointPosition(i, starLocs[i].position);
pl.SetPointColor(i, Color.clear);
}
StartCoroutine(UpdateColors(pl));
}

private IEnumerator UpdateColors(Polyline pl)
{
sq = DOTween.Sequence();
yield return new WaitForSeconds(.5f);
for (int i = 0; i < pl.Count; ++i)
{
yield return DOTween.To(() => pl.points[i].color, x => pl.SetPointColor(i, x), color, fadeInTime).WaitForCompletion();
}
//yield return sq.Play().WaitForCompletion();
}


This is the code that I'm using now, not in immediate mode. Basically in the inspector I have the color of every point set to white and then I just change it to clear. Seems like I can only increase the alpha if I decrease it first.