How can I change Texture Editor Settings from a plugin

Hi,

I’m trying to import textures and meshes from an external directory through an editor plugin. I’ve managed to achieve this by using the FAssetToolsModule’s function ImportAssets. Now I’m trying to improve the import times by changing texture settings like MipGenSettings and CompressionSettings. I’ve two specific questions:

  1. Is it possible to change these settings BEFORE invoking the call to ImportAssets ? I’ve tried doing something like the following, but it didn’t quite work:

    UTextureFactory * TextureFactory = ConstructObject(UTextureFactory::StaticClass());
    TextureFactory->MipGenSettings = TextureMipGenSettings::TMGS_NoMipmaps;
    TArray<UObject*> ImportedAssets = AssetToolsModule.Get().ImportAssets(FileNames, DestPathTexture, TextureFactory);

  2. If the above isn’t possible, then can we change the above mentioned settings through code (in the same way we change them through the Editor) ?. I’ve been unable to find the right class/object/method to update these.

So apparently we CAN change these settings on the texture objects. It was only a matter of using a compiler directive to set these settings (since these members were marked as editor only:

#if WITH_EDITORONLY_DATA
		texture->CompressionNone = true;
		texture->MipGenSettings = TMGS_NoMipmaps;
#endif

Looking at the code in the engine source. It seems that the TextureFactory settings are ignored since the factory object you pass in might not directly be used to create the binary. Hence our option was to set these values on the texture objects instead.

Hi SameerMirza :

I tried your code,I wonder how to define the AssetToolsModule,like this:

FAssetToolsModule AssetToolsModule;
TArray<UObject*> ImportedAssets = AssetToolsModule.Get().ImportAssets(FileNames, DestPathTexture, TextureFactory);

and it doesn`t work!

can you give me some advice?

Thanks a lot!