Search Unity

How can I set the wrapmode of a texture in a MaterialPropertyBlock?

Discussion in 'General Graphics' started by Phedg1, Jun 14, 2019.

  1. Phedg1

    Phedg1

    Joined:
    Mar 3, 2015
    Posts:
    113
    I can set a texture on a material and make that texture have the .wrapMode = TextureWrapMode.Repeat and the texture will tile perfectly. However, when the texture is set through a MaterialPropertyBlock and that property block is applied to a Renderer instead, I can't seem to get it to repeat.

    Code (CSharp):
    1. myTexture.wrapMode = TextureWrapMode.Repeat;
    2. myPropertyBlock.SetTexture("_MainTex", myTexture);
    3. myRenderer.SetPropertyBlock(myPropertyBlock);
    How can I make a MaterialPropertyBlock tile/repeat its texture?