- Home /
Multiple texture import settings?
Hi,
I'm working on a project for Android devices. In order to make it runnable on both tablets and mobile phones, I'm going to create 2 seperate builds with slightly different settings.
The only problem is the size of the textures. When I build for tablets, the textures can be imported at their full size, but for mobile phones, I should be able to set them to about half their size.
Now, my question is: Can you have multiple import settings for textures, so I can keep my app in one project. The main idea is to keep it in one Unity project, so when I would have to make changes in the code, I wouldn't have to do this constantly in two projects.
Any thoughts on how I should handle this?
Thanks in advance,
Tim
Answer by Wolfram · Jun 19, 2012 at 10:52 AM
Two possibilities:
globally: in the Quality settings, choose/create a different default quality for mobile than for your other builds, and set its "Texture Quality" to "Half Res"
per texture: in the Texture inspector, there are pplatform icons to the right of "Default" (just above the "Max Size" setting). Click on your mobile platform, check "override", change Max Size.
(EDIT, before even posting...): Darn, now that I read your question again, you are trying to differentiate between two Android settings. So my second approach will not work. But you can still use my first approach, just switch between "Full/Hald Res" when building for one or the other.
Yeah, must have looked over that setting in the Quality settings. This is really what I needed.
Thanks
Do you know if I put the texture Quality to "Half Res", if the assets are fully loaded into memory? To clarify my question, if I have an original texture of 1024x1024 and I set the quality setting to "Half Res". (which basically takes the first mip-map) Is the original texture fully loaded into memory, or only the first mip-map?
Hm, I investigated this a little further, and it seems the "Texture Quality" option really does just enable a lower $$anonymous$$ip$$anonymous$$ap level, ins$$anonymous$$d of using actually a smaller resolution texture. This means:
The original texture is still included in the build, even if all Quality settings with "Full Res" are disabled. Therefore your build size will not change.
The texture will still be displayed at full res if it has "Generate $$anonymous$$ip $$anonymous$$aps" disabled in its import settings.
At least for windows builds, the used memory of the running app is lower, suggesting the full res textures are not loaded. Not sure how this behaves for Android.
So it seems this setting really is a crude workaround. It will not help you reduce the build size, although it might help reducing the memory footprint.
Thanks man, the build size isn't really an issue, but the memory footprint is. Thanks for your help!
Answer by sooncat · Jun 19, 2012 at 10:56 AM
This is my way to solve this problem, need click it every time before build:
[Menu(.../...)]
static void set()
{
//open editor window here
}
void Setting(int diff)
{
foreach (string s in allTextures)
{
TextureImporter import = AssetImporter.GetAtPath(s) as TextureImporter;
Texture2D t = (Texture2D)AssetDatabase.LoadAssetAtPath(texturePath, typeof(Texture2D));
int max = Mathf.Max(t.width, t.height);
max = Mathf.NextPowerOfTwo(max);
import.SetPlatformTextureSettings("Android", max >> diff, import.textureFormat);
import.SetPlatformTextureSettings("Web"......);
......
}
}
It's a troublesome thing to click the menu befor build every time.
So I will pay attention to this issue waiting for a clever way.
Thanks for the sample code, but for my project specifically, setting the textures to half size should suffice. I just wasn't aware of that setting in the quality settings.
Thanks anyway!
Your answer
Follow this Question
Related Questions
Better to use multiple objects or textures with basic paperdolling? 0 Answers
Set Import Setting When an Audio Clip is Dragged into the Project 0 Answers
Disabling mip map turns texture normal 0 Answers
Material tiling on imported fbx model doesn`t fit 0 Answers
Meshes with multpile texture maps--is it possible? 3 Answers