Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Why do I have "MaterialPropertyBlock is used to modify these values" on all materials?

Discussion in 'General Graphics' started by Xarbrough, Mar 4, 2017.

  1. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    1,184
    I've just noticed that all materials in my project show this warning. I can't think of anything weird I'm doing. Most of my objects are 2D sprites with the original Sprites-Default material. Some sprites have a particle shader, which is not strictly speaking made for the Sprite Renderer, but still works fine.

    When I create a new empty sprite, the Sprites-Default material gets assigned, everything is normal. When I now add one of my sprite assets to the Sprite Renderer, the warning appears in the material inspector.

    I am not using the MaterialBlock API in code and I'm not animating the materials via the Animator. At least, not that I know of.
     
  2. mingwai

    mingwai

    Small Graphics Potato Unity Technologies

    Joined:
    Jan 16, 2017
    Posts:
    51
    This is because the Sprite Render uses MaterialPropertyBlock to assign the sprite texture into the material (shader). This is why you are able to use different sprites on Sprite Renderer, while just having a single material.

    The default sprite shader has the tag which is to hide the _MainTex property on material, so you are not able to see the "texture slot" on the material.

    Other shaders like Particle ones are having _MainTex property visible, but once apply to Sprite Renderer, the "texture slot" on Particle materials will have no effect.
     
  3. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    1,184
    Thanks, that does sound logical. So it's not a real issue. Still, it is weird, that it shows as a warning, always looks like something went wrong.

    I think it makes a lot of sense, that the warning shows, when using the regular particle material, since like you explained, the _MainTex slot will be overridden by the sprite, but the warning also shows on a regular sprite with the default sprite material, where there's no ambiguity between which texture is used.
     
    Last edited: Jul 27, 2017
  4. mingwai

    mingwai

    Small Graphics Potato Unity Technologies

    Joined:
    Jan 16, 2017
    Posts:
    51
    Agree. Thanks for your feedback. We have passed the case to devs :)
     
  5. poM2

    poM2

    Joined:
    Jul 13, 2015
    Posts:
    8
    I have got the remark on animtated material in unity5.6.0f3 and unity5.6.0p1 also.

    I change the color of material with animator.

    What is your recommend?
    Am I have keep an eye on the remark?
     
  6. npatch

    npatch

    Joined:
    Jun 26, 2015
    Posts:
    228
    Changing material properties in animations also work with MaterialPropertyBlocks.
     
  7. TheRedGuy90

    TheRedGuy90

    Joined:
    Dec 5, 2014
    Posts:
    117
    The images I am using to animate my material are Textures and not Sprites, so why am I getting this error
     
  8. npatch

    npatch

    Joined:
    Jun 26, 2015
    Posts:
    228
    Doesn't matter. MaterialPropertyBlock is something that works with any renderer(perhaps short of CanvasRenderer,not 100% sure there). Just so happened that OP was using a SpriteRenderer.
    Are you trying to change the texture through code as well as through animation clip?

    Read this to understand MaterialPropertyBlocks better. Using them will make rendering faster and it's something that's used under the hood in some parts like animations,by default.
     
    Last edited: Mar 14, 2018
  9. TheRedGuy90

    TheRedGuy90

    Joined:
    Dec 5, 2014
    Posts:
    117
    No, just animation clip.
     
  10. npatch

    npatch

    Joined:
    Jun 26, 2015
    Posts:
    228
    Does the error show up in Console? Or on the inspector?
     
  11. TheRedGuy90

    TheRedGuy90

    Joined:
    Dec 5, 2014
    Posts:
    117
    Inspector
     
  12. npatch

    npatch

    Joined:
    Jun 26, 2015
    Posts:
    228
    It's not an error then.As you can see from the link in my previous response, this is something that's there as a warning. Since you're modifying something in an animation clip, it warns you that you basically can't modify that property in code. If I remember correctly, trying to change the value through code will compile and play without errors, but since a value is being changed through animation clip it has higher priority so any changes through code are going to be overritten by the animation clip.
     
  13. TheRedGuy90

    TheRedGuy90

    Joined:
    Dec 5, 2014
    Posts:
    117
    Wait, are you saying that I SHOULD be able to animate it?

    I'm not coding anything.
     
  14. npatch

    npatch

    Joined:
    Jun 26, 2015
    Posts:
    228
    Yes ,unless I'm misunderstanding something,you should. MaterialPropertyBlocks is just what's used to store values in certain cases when animating stuff.
     
  15. TheRedGuy90

    TheRedGuy90

    Joined:
    Dec 5, 2014
    Posts:
    117
    Okay, I'd like to DM you about my current issue if thats okay
     
  16. vinnykeller

    vinnykeller

    Joined:
    May 31, 2017
    Posts:
    3
    npatch... Thanks for including the link to the article on materialipropertyblocks . Article was helpful.
     
    npatch likes this.