- Home /
Do textures for materials need to be in Resources folder also?
So I've been trying to reduce the build size of my project by removing files from the Assets/Resources folder, and i was wondering if the texture (image) files for the materials I've used on my models are required to be in the Resources folder in order for the material to work properly.
Bearing in mind I'm just moving the file, not deleting it entirely. Have noticed some oddities sometimes with Unity when I move a file from one place to another.
Any help, or point in the right direction, would be a great help. Thanks :)
Answer by supernat · Feb 01, 2014 at 04:27 AM
The Resources folder is primarily for adding assets that you want to load dynamically at runtime. You definitely don't want to store anything in there that isn't used at runtime. When you call things like LoadResource("texture"), it looks in the Resources folder. Unity guarantees it will copy the Resources folder to your app. Anything outside of the Resources folder will only be copied if it has a direct reference to a scene in the editor.
Here's a link to the help page: http://docs.unity3d.com/Documentation/ScriptReference/Resources.html
Regarding moving files, if you move them in the Editor, you are safe (for the most part). If you move them in Windows Explorer or Mac Finder, not so much. Also, I noticed that having the meta data enabled for version control leads to less unrecoverable loss of scenes. I think that may be on by default now days though.
To address your specific question, your textures will be fine if they are assigned to a shader that is assigned to a material that is referenced by a prefab or existing object, and I also believe the code is searched for any material overrides by name (not certain, but I don't recall ever having issues doing that with missing textures on the final output).
Thanks a lot for the detailed explanation. Have tested it out and so long as the material is still referencing the image file, it doesn't matter where in the Assets folder the image file lies. $$anonymous$$eaning that i have been able to remove a lot of files that don't need to be compiled for the build.
Thank you again :)
Your answer
Follow this Question
Related Questions
3d model editing and multiple textures per material 0 Answers
Hownto apply textures to materials in unity 5? 4 Answers
Texturing a large surface 2 Answers
Transparency Drawing issues 0 Answers
Skinned Mesh Renderer Material 1 Answer