I’m building a 3D FPS game for Android with Unity 2017.2.0p2. My build size was initially 216mb and I have managed to get it down to 68mb so far. I’m trying to decrease the size further. Looking at the logs for the latest build, I see that shaders are currently taking 34mb (35%). I’m trying to remove unused shader/variants. Currently, Unity tells me: “Currently tracked shaders: 23 shaders 165 total variants”. Exporting this information (attached here) shows a lot of variants with DYNAMICLIGHTMAP_ON. I’ve double checked that I’m not using baked lighting in any of my scenes, “Mixed Lighting” is off in all the scenes and there’s absolutely no lighting data in my project. How can I remove these shader variants from my build? Why are they being included in the first place?
[Update] I cleared the tracked shaders and I think all unwanted shaders are now out of the currently tracked shaders. But the build size only decreased by ~1mb. So I’m currently investigating if some of the used shaders are too big or if there’s some other issue.
Make sure you uncheck those lighting modes in Project Settings > Graphics > Shader Stripping. You can set Lightmap mode to Custom and uncheck the modes you don’t want variants for.
Also make sure “Instancing Variants” isn’t set to “Keep All”
Hello Invertex, thanks for the reply
Attached are my settings for stripping. I think I had already done everything that I could. Please confirm if the settings are fine.
Those were the settings before I posted the thread.
Anyways, the problem went away and I don’t know how. I just started deleting materials left and right and did a lot of other crazy optimization stuff like manually editing the scene files in a text editor to make sure that everything is just like intended, checking where each shader variant could potentially come from, experimented with excluding stuff one by one from the project, converted all PSDs and TGAs to PNGs, etc. It was taking ages to build with all the shaders, now it takes less than a minute.
Thanks for helping me @Invertex