Home > Blockchain >  How to add the Default-Line material back to the LineRenderer material?
How to add the Default-Line material back to the LineRenderer material?

Time:05-15

If i'm starting with the linerenderer materials and the first place is empty without any material the linerenderer is pink and then i'm trying to add the Default-Line material to the linerenderer in the Start :

void Start()
    {
        myLineRenderer = GetComponent<LineRenderer>();
        Material defaultLine = new Material(Shader.Find("Default-Line"));
        myLineRenderer.material = defaultLine;
    }

but the linerenderer materials is empty.

if i'm trying for example this it will add the Standard material :

private Color ggg(Color color)
    {
        Material standrad = new Material(Shader.Find("Standard"));
        standrad.color = Color.red;
        myLineRenderer.material = standrad;
        return color;
    }

So why it's not adding the Default-Line ? When adding the Default-Line the materials is empty.

CodePudding user response:

This is because Unity has moved the addresses of the default materials. For default line; Copy the script below:

    myLineRenderer.material = new Material(Shader.Find("Legacy Shaders/Particles/Alpha Blended Premultiply"));

In fact, you should follow its previous address from Shader.

enter image description here

  • Related