Search Unity

How to put Sprite-Default material to LineRenderer with code ?

Discussion in 'Scripting' started by Gr00vy_, Sep 26, 2022.

  1. Gr00vy_

    Gr00vy_

    Joined:
    Aug 2, 2022
    Posts:
    10
    Hello all,

    I just want how can I found the right pathway to found the right emplacement of the Sprite-Default material with code ? ( I want to assign it to every line who are generated in a array when the script is executed so I cannot put it manually on the inspector ).

    Thanks a lot.
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,736
    You can create any Material you want in the editor.

    You can drag it into a public field on a script.

    You can also drag in Renderer components into that same script.

    Using the Renderer reference you can assign the Material to the .material slot on the Renderer.