Thursday, January 20, 2011

Maya caching UI images?

I'm curious if anyone else doing Maya UI development has noticed that Maya will cache images used in UI elements, and not refresh them if the image data changes. I haven't done a thorough test to see if it's specific to certain image formats, as I'm only using XPM files, but this problem has been there for ages. If you haven't seen it in action, try this:
  • Make a small image (100 x 100 is good) in your favorite image editing application, and save/export it in XPM format.
  • Script a simple Maya interface that assigns this image to a control, like the iconTextButton. Open your UI and confirm that the image displays correctly.
  • Go back to your image editing app, make some obvious change to the image, and save/export it with the same name as before.
  • In Maya, reload your UI, and you should still see the original image, without the change you just made.
  • Restart Maya and load your UI again. The changed image should appear this time.
I've tried a number of things in an attempt to work around the problem, but it appears that the only way to force Maya to see the change in the image file is to close it and re-open it. Not exactly the most productive option.

If the test above doesn't operate as described for you, I'd love to hear about it. Post the Maya version and OS that you're using. I'm curious if there's a pattern to this problem. I'd also appreciate hearing if you know of any proven work-arounds.

2 comments:

mattanimation said...

Actually noticed the same thing with a GUI I was working on and had to do the same thing to refresh it; Open it and close it again. I was using Maya 2011 running OSX snow leopard. Solution? Just wait till I HAD to see the image to actually open and close it.

Justin S Barrett said...

Unfortunately this kind of solution won't work in the tool that brought the problem to my attention. In that situation, the user is doing something that is supposed to change the image. Because the image isn't changing, it adds a kind to their workflow.