Applying gradient by Sprite Creation or Material

So basically I am going to create a few small gradient bars, similar to the ones seen in all unity components that allow the usage of a gradient(line renderer for one). But I couldn’t use the line renderer for this purpose because it’s inset into the UI canvas. And we are using orthographic cam with zoom function so that the line renderer would require code to counteract these effects, and I don’t want to give it this code.

but on point; the decision here is
create or a overwrite a sprite to contain a gradient when function is called by script where sprite pixel data paints the gradient. OR use a material and update the material gradients.

Orr??? Is there another way

now the reason there is even a post here is because I need multiple gradients and don’t necessarily want to use multiple materials. So just wondering if anyone has any encouragement on which is best. How long will it take to create a small 1 pixel x 100 pixel line of colours in sprite by script?

Thanks

nevermind i made this

    public Sprite GradSprite;
    public List<int> DummyPercentages;

    void MakeGradient()
    {
        var Z = new List<Color>();
        Z.Add(P1);
        Z.Add(P2);
        Z.Add(P3);
        Z.Add(P4);
        Z.Add(P5);
        Z.Add(P6);
        Z.Add(Color.black);

        int k = 0;

        var Tex = GradSprite.texture;
        for (int i = 0; i < Tex.GetPixels().Length; i++)
        {
            if (i < DummyPercentages[k])
            {
                Tex.SetPixel(i, 0, Z[k]);
            }
            else
            {
                Tex.SetPixel(i, 0, Z[k]);
                k = k + 1;
            }
        }
        Tex.Apply();
    }

So the list DummyPercentage has to go
0- X%
X% - Y%
Y% - Z%
Z% - A%
A% - B%
B% - C%
Start 0% End 100%
etc so on and so forth. Very easy in the end. This is for a 100x1 pixel texture.

is improved later on with
void MakeGradient(List<int> Percentages, List<int> ColorOrder)

7920349--1010725--4E63B867-77B8-475D-A546-B6D30570CF0D.gif

Wow is so easy an surprised