Author Topic: Understanding how does UISprite send a color change for custom Shader  (Read 1840 times)

Lustabel

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 5
    • View Profile
I'm using a custom shader, but I cannot find the arguments at NGUI script to change the material tint color to apply it to my custom shader.



Thank you very much for the help.

Lustabel

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: Understanding how does UISprite send a color change for custom Shader
« Reply #1 on: February 01, 2017, 05:59:43 AM »
Would be enough for me to find the object to access to it's current material to edit it and assign it to the object via script.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Understanding how does UISprite send a color change for custom Shader
« Reply #2 on: February 04, 2017, 03:51:09 AM »
NGUI widgets color is effectively baked as vertex colors when the widget geometry gets created and sent to the GPU. It's not a part of the material.

Furthermore, since you didn't specify an explicit material on your sprite, it means NGUI will batch this sprite with all the other sprites using the same atlas underneath its parent panel. So there is no "one" draw call for the sprite. There is one draw call for all the sprites -- and as such only one material. You can listen to UIWidget.onRender to get the final material, but like I said it will be a batched material for all of your widgets in the batched draw call.