- Home /
TextureImporter and AssetDatabase.ImportAsset
Hello. As part of an AssetBundle build process I want to modify the maxTextureSize of textures at runtime.
I've searched for how to do this, and found a few examples, but my code doesn't seem to work:
Texture2D tex = (Texture2D)material.mainTexture;
string texPath = AssetDatabase.GetAssetPath( tex );
TextureImporter textureImporter = (TextureImporter)AssetImporter.GetAtPath( texPath );
textureImporter.maxTextureSize = 512;
AssetDatabase.ImportAsset( texPath, ImportAssetOptions.ForceSynchronousImport | ImportAssetOptions.ForceUpdate );
int stophere = 1;
I would have expected that if I put a breakpoint on the "int stophere = 1" and view tex.width and tex.height in the watch window I would see the effects of the re-import.
Is this an incorrect assumption? Thanks in advance.
Your answer
Follow this Question
Related Questions
Disabling reimport before building of AssetBundle 0 Answers
Reimporting assets takes a long time and doesn't show loading screen 0 Answers
Running AssetDatabase.ImportPackage on multiple packages 3 Answers
importing mesh as combined and reimport 0 Answers
5.3 project says it is 5.0 when importing repository on different computer, breaks project 0 Answers