Question regarding UILayout.template_preview


I am have been experimenting with creating a content creator helper tool for an external platform I am participating in. In this case, I am trying to make an addition to the Materials panel to allow for modified values to be added from a single place, without having to know every step needed:

Unfortunately I have hit a small snag: with the template_preview.

While this doesn’t stop the functionality, I’d like to show the textures selected already from the panel, without having to goto to the Textures panel to check things out, this is just a shortcut to check.


  • When I render it inside a Panel, (under Properties > Materials ) within the draw method begins to be recursively called (loading the preview texture triggers the draw call again, causing the preview to be loaded again), and the preview image never, recovers. Plus on some systems this is very, very taxing.
  • Panel seems to call the draw even when ever I move my mouse ontop of a button, is there a way to optimize this

Source available here

Anyone have any pointers what should be done to stop this recursive loop?