I created an editor script that helps me change the settings on textures automatically so that I don't have to. It works for the most part except for changing the texture importer isReadable = true. If the texture isn't readable, a dialog box pops open saying "Unapplied import settings" and then asks me to Apply or Revert. Even when I press "Apply", I double-check the texture and isReadable is still set to false. Is there any code that will allow me to "Apply" the import settings?
Here's a snippet of my code (I'm using C#):
string path = AssetDatabase.GetAssetPath(texture);
TextureImporter textureImporter = AssetImporter.GetAtPath(path) as TextureImporter;
if (textureImporter.isReadable == false)
{
textureImporter.isReadable = true;
AssetDatabase.ImportAsset(path);
}
I've also been trying to get this working, and have found a few things. This is the bare minimum code you need to get it working, and also it has to be in this order - if you change the filtering/anis/clamp modes, and -then- change the importer settings, it loses the previous changes. This is as of Unity 3.1, tested and confirmed on a Win7 PC.
You'll have more luck when trying a AssetPreProcessor instead. (In fact, I didn't even know you could do what your example shows. Learn something new every day :) )
Here's a link to the help which includes an example usage:
I have the same issue by using the texture import settings from Unity Community wiki. If I click apply on the popup, then the current active selection texture object won’t get update. Though I didn’t find a perfect solution, but if you click revert on the popup, everything works fine.
I am reproducing the same issue when using TextureImporter.SetPlatformTextureSettings().
My editor script works fine (and updates the platform override settings) only if the texture in question is NOT selected.
I notice that the texture settings script from the wiki sets Selection.objects to an empty Object array before it operates on textures. I tried using the same approach in my script, but it throws an InvalidCastException.
It might be worth mentioning that (for some silly reason) I’m using javascript…