Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Changing extruded renderer's material runtime
#1
Hello,

I have a logic where I need to change the ropes material during runtime. I tried setting obiRopeExtrudedRenderer.material = new Material(copyFrom); it looks like the material is changed in the component itself but it doesn't effect the renderer. I assume this is cached on start. Is there a way to do this?

Thanks
Reply
#2
Hi,

Yes, you just need to flag the renderer dirty after changing the material:
Code:
((ObiActorRenderer<ObiRopeExtrudedRenderer)renderer).SetRendererDirty(Oni.RenderingSystemType.AllSmoothedRopes);

This will refresh the material and trigger a re-batching of all ropes to minimize the amount of batches next time the rope is rendered. Note this is a somewhat expensive operation.

kind regards,
Reply
#3
Corazón 
Thank you! I am amazed how robust you guys made this API as always  Corazón
Reply