Search Unity

Is there a way to access the overwritten per object materials in a renderer?

Discussion in 'General Graphics' started by NathanJeeves, Jul 2, 2021.

  1. NathanJeeves

    NathanJeeves

    Joined:
    Jul 6, 2015
    Posts:
    27
    I have set a bunch of colors through the MaterialBlockProperty functionality, now my next part of my code wants to access the material colors of these objects, but that is just black because it hasn't been changed, the renderer has overwritten it on each object to color them, how do I access the overwritten properties of a renderer? there is a propertyBlock.getColor function, but there is no way to get the propertyblock in question from the Renderer?

    Any help would be greatly appreciated.

    Cheers
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    You set the color via
    renderer.SetPropertyBlock(matBlock)
    , there's a matching
    renderer.GetPropertyBlock(matBlock)
    you can (and should!) use to access the block that was set.