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

Bug Sprite Shape Controller doesn't update material information

Discussion in '2D' started by UDN_46c91c6c-aeb1-471f-87fb-917fc1db02c9, Oct 22, 2023.

  1. UDN_46c91c6c-aeb1-471f-87fb-917fc1db02c9

    UDN_46c91c6c-aeb1-471f-87fb-917fc1db02c9

    Joined:
    Dec 3, 2017
    Posts:
    21
    The problem is simple:

    1. I have a shader that draws the sprite texture with a color defined in the material.
    2. I assign the material created with that shader to a Sprite shape controller.
    3. I have a script that under certain conditions changes the color of the material.

    The problem is that Sprite Shape Controller doesn't update the material information despite pointing to the material I modified. The only way I can see the changes is by modifying the shape, enable tangents or whatever other option that internally updates the information of the GameObject.

    I tried placing the same material in a regular SpriteRenderer. It works. Every SpriteRenderer that uses the material changes color when the conditions are met. The ones who remain using the old material configuration are the SpriteShapeControllers. If I modify the shape it updates.

    This is a problem, probably due to some internal optimization. Is there a workaround?
     
  2. UDN_46c91c6c-aeb1-471f-87fb-917fc1db02c9

    UDN_46c91c6c-aeb1-471f-87fb-917fc1db02c9

    Joined:
    Dec 3, 2017
    Posts:
    21
    Some updates. I have been trying to force the refresh of the mesh through a script. It works, but it slows down the game to a crawl.

    I don't understand the logic behind the material not being updated when modified. I am simply being forced to drop Sprite Shape completely if someone cannot offer me a solution.
     
  3. DanielTanBK

    DanielTanBK

    Unity Technologies

    Joined:
    Aug 20, 2019
    Posts:
    80
    Hello, thanks for reporting this issue.
    Could you file a bug using the bug reporter and let us know the case ID sent to your email?