Mass Filter Mode Change?

I’ve been using Martin Schultz’s ChangeTextureImportSettings.cs (found here) for changing texture properties en masse, but another feature I need is the ability to change the filter mode the same way. I’m fairly new to JavaScript - would anyone be able to help with this?

Here’s an example of how the code looks for changing texture size:

    [MenuItem ("Custom/Texture/Change Texture Size/Change Max Texture Size/1024")]
    static void ChangeTextureSize_1024() {
        SelectedChangeMaxTextureSize(1024);
    }
    static void SelectedChangeMaxTextureSize(int size) {
   
        Object[] textures = GetSelectedTextures();
        Selection.objects = new Object[0];
        foreach (Texture2D texture in textures)  {
            string path = AssetDatabase.GetAssetPath(texture);
            TextureImporter textureImporter = AssetImporter.GetAtPath(path) as TextureImporter;
            textureImporter.maxTextureSize = size; 
            AssetDatabase.ImportAsset(path);
        }
    }

I’m having difficulty modifying this because FilterMode is not part of the TextureImporter class, it’s part of Texture2D.

Thanks,
Digeridude

I’m pretty sure I have some of this right. Blue parts I’m unsure about, and red parts I’m completely stuck on.


[MenuItem (“Custom/Texture/Change Filter Mode/Point”)]
static void ChangeFilterMode_Point() {
SelectedChangeFilterMode(FilterMode.Point);
}


static void SelectedChangeFilterMode(FilterMode newMode) {

Object[ ] textures = GetSelectedTextures();
Selection.objects = new Object[0];
foreach (Texture2D texture in textures) {
string path = AssetDatabase.GetAssetPath(texture);
TextureImporter textureImporter = AssetImporter.GetAtPath(path) as TextureImporter;
textureImporter.maxTextureSize = newMode;
AssetDatabase.ImportAsset(path);
}
}


No importer, just texture.filterMode = whatever, as long as texture is referencing an asset.

Sorry, didn’t quite understand that. Could you be more specific?

Hi, some parts of the texture settings take effect after import, and are not set by the importer. What you need is to have your editor script modify the Texture2D that’s in the Project view directly.

Ah, well then I think I need to learn more before I can tackle that. Until now I’ve gotten by modifying existing scripts.

I find it a lot more useful to set one texture up the way I want, and copy the settings to a bunch of other textures (this only matches every single setting for iOS)

373274–12917–$matchtexturesettings_778.cs (2.51 KB)

Thanks! That helps a bunch.