alphaKeys in linerenderer gradient not being set

I’m using a gradient on a linerenderer, more specifically it’s alpha, to make an effect of moving in and out of the ground. In theory this should work fine, but wherever I attempt to actually SET any kind of variable in the gradient, it doesn’t work.

Renderer.colorGradient.alphaKeys[alphaPos].alpha = pos.z; (where alphaPos is which key to edit (out of 8. There will always be 8 in my circumstance, not that me setting it to have 8 does anything anyways)

Renderer.colorGradient.SetKeys(Renderer.colorGradient.colorKeys, newKeys), or Renderer.colorGradient.alphaKeys = newKeys (where newKeys is an array of the alphaGradientKeys) also do not work.

If I were to print pos.z and Renderer.colorGradient.alphaKeys[alphaPos].alpha, pos.z would be, say .5f, .7f, .100000003f, etc... the Renderer.colorGradient.alphaKeys[alphaPos].alpha would remain to be 1, and never be changed.

Edit: Making a new gradient and assigning it’s alphaKeys, and then setting the colorGradient to that new gradient works, but even in that case I cannot manually set newGradient.alpha. This is troubling as I need this process to be as optimized as possible because this is happening many times per frame.

GradientAlphaKey alphakeys = new GradientAlphaKey[c.alphaKeys.Length];
for (int j = 0; j < c.alphaKeys.Length; j++)
alphakeys[j] = new GradientAlphaKey(c.alphaKeys[j].alpha * _alphaPulse, c.alphaKeys[j].time);
_lineRenderers*.colorGradient = c;*
you just need to generate a brand new gradientalphakey and apply it instead of just changing the value in it.