Jump to content

How do you check if a texture file exists?


Sinhika
 Share

Recommended Posts

Before I start rolling my own code, I thought I'd ask to make sure I'm not re-inventing the wheel. Is there an easy way (aka, a pre-existing function/class/method) for checking if an icon or texture file exists before registering it?

 

The use case I'm looking at is where my mod has a custom tool (call it cTool), and during postInit, the mod checks to see if any other mods have added custom tool materials. If so, my mod then auto-generates more cTools made with the added custom materials. These auto-generated cTools need icons; if I've heard of the mod, I may have already created an icon for custom-material cTool; if so, all well and good. However, if I haven't, I'd like the option to fall back to some generic-looking icon rather than tossing up a "Missing Texture" icon.

Link to comment
Share on other sites

Actually, my mod does not "know" what textures exist; it just blithely assumes that when it synthesizes a texture name from material & tool suffix, then that texture exists.

 

Is there a handy way to enumerate over the contents of an assets directory?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.