Why these files even if they are not in the scene I build, they get BUILT into the APK ? It says from the console log they are taken from the resource folder but they are not! Check their path! Why is that ?
Not even from other references! How can I check them ?
Used Assets and files from the Resources folder, sorted by uncompressed size:
16.0 mb 1.$% Assets/Yogo/Particle Systems/UltimateMaster VFX/1 - Assets/Textures/Particles/Spritesheets/tex_particle_spritesheet_lensflare.png
5.3 mb 1.$% Assets/RunnerEngine/Common/Sprites/GUI/life-lost-effect.png
What you can try is switching the asset serialization mode to “force text” and search for the GUID of the asset in all files in your project. However this can’t be done with the windows file search as it doesn’t properly search through all files (stupid content filters).
In general you would do it like this:
- Go to “Edit → Project Settings → Editor Settings” and set the Asset Serialization Mode to “Force Text”.
- Next rightclick the asset you want to fine the references to and select “Show in Explorer”.
- Open the “.meta” file in a text editor and copy the “guid” of the asset.
- Now use a search tool that is able to actually search through all files in your assets folder and search for this guid. It can be referenced from scenes, materials, prefabs or even from other .meta files in case of script default references.
I quickly thrown together a simple editor window which might help to find references to assets / objects inside the Unity editor. Just place it in a folder called “editor” inside your assets folder. You can open the window from the main menu (Tools–>B83–>FindReferences).
You can drag one or multiple objects you want to find out who is referencing them into the “Add” object field. When you click “Search” it will try to find references to those objects. It looks though all assets that are reported by the AssetDatabase. Additionally it will search through the hierarche of all loaded scenes. It does not search scenes which are not currently open.
When the search is done you will see all found references listed right below each of the search items. The results are indented a bit. The results provides you an object field with the asset / object that actually contains the reference and a string that should tell you exactly where that reference is stored. If you have trouble interpreting the result, just copy it and post it as comment here.
Note that this is not guaranteed to find all references. Also it doesn’t tell you what is included in a build. It just should help to track down some hidden references.
I first thought about using reflection to manually dig through the object graph, however this would be way too complicated as all built-in components do not have any fields but only properties. There would be endless special cases. Instead i just use Unity’s serialization system (SerializedObject + SerializedProperty). It provides all serialized data and nothing else.
For some reason iterating through some materials in my project takes quite long. I have no idea why.
Important: Before you use this helper script make sure you saved all your work. During the search it will load every single asset in your project into memory in order to examine them. On large projects this could take some time and in the worst case might crash Unity.