Issues with changing alpha value of Polyline in Immediate Draw mode
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.
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.