Search Unity

  1. Get the latest news, tutorials and offers directly to your inbox with our newsletters. Sign up now.
    Dismiss Notice

Resolved Graphics.DrawMesh cannot set color with material

Discussion in 'General Graphics' started by glorog, Apr 5, 2021.

  1. glorog

    glorog

    Joined:
    Apr 5, 2021
    Posts:
    2
    Hi, I'm stuck with graphics, Idk what I'm missing...

    Inside OnDrawGizmos, outside playmode I'm trying to draw mesh:
    Code (CSharp):
    1. mat.SetColor(ColorProp, Color.red);
    2. Graphics.DrawMesh(mesh, Matrix4x4.identity, mat, 0);
    Why after those 2 lines I still having basic grayish color for mesh?
     
  2. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    7,559
    Try setting the color to a material property block and then supply it with your DrawMesh command.
     
  3. glorog

    glorog

    Joined:
    Apr 5, 2021
    Posts:
    2
    @up I wasn't confident to use it, because I couldn't find how to use MPB with DrawMesh. Apparently I can just create it and don't have to feed it with GetPropertyBlock like in Renderer.
    It works! Thanks
     
unityunity