3
\$\begingroup\$

I have a texture in my assets, and I need to find out where it's being used so that I can change some textures in my project.

How can I find out where a specific texture is used in my project?

The case is that the game needs to be updated to have a Christmas look, so there are a few game textures should be replaced.


This resource checker does not work for me. It shows that there are no textures even though there are:

"textures 0 / materials 0"

\$\endgroup\$
  • \$\begingroup\$ You can just right click the asset and search in your scene. \$\endgroup\$ – Sidar Nov 26 '17 at 14:14
2
\$\begingroup\$

To solve the problem just create a script that assigns a texture to a material based on a specific condition. The script should contain the two textures, and it should also get the object material. All you have to do is assign this script to each object you want to change the material's texture to.

If you want to see where a texture/ or a resource is currently being used in your game/scene here is a good tool which lets you do it: Unity Resource Checker

Also check out this thread for more information.

\$\endgroup\$
  • \$\begingroup\$ Does not work for me. I updated the question. \$\endgroup\$ – trafalgarLaww Nov 26 '17 at 14:06
  • \$\begingroup\$ Have you tried creating a script that automatically switches a material's texture? Are you in playmode while using Resource checker or not? \$\endgroup\$ – user100681 Nov 26 '17 at 14:09
  • \$\begingroup\$ I am not in a playmode. \$\endgroup\$ – trafalgarLaww Nov 26 '17 at 14:10
  • \$\begingroup\$ @trafalgarLaww then try running the game in the editor and THEN using Resource Checker. \$\endgroup\$ – user100681 Nov 26 '17 at 14:11
2
\$\begingroup\$

If you're comfortable with using the command line, you could look through every file in the project for the texture's guid. On my Mac, I have added these functions to my .bash_profile which helps in this regard:

function findasset(){
  LANG=C;
  guid=$(find . -iname "$1".meta -print0 | xargs -0 grep guid: | cut -d" " -f 2);
  echo $guid;
  findguid $guid;
}
function findguid(){
  LANG=C;
  guid=$1;
  find . -iname "*.unity" -print0 | xargs -0 grep $guid;
  find . -iname "*.prefab" -print0 | xargs -0 grep $guid;
  find . -iname "*.mat" -print0 | xargs -0 grep $guid;
  find . -iname "*.controller" -print0 | xargs -0 grep $guid;
  find . -iname "*.anim" -print0 | xargs -0 grep $guid;
  find . -iname "*.asset" -print0 | xargs -0 grep $guid;
}

Then, in my terminal window, I navigate to the project's root Assets folder, and simply type, for example, findasset mytexture.png and as long as that filename is unique within the project, it will print out all of the Scenes, Prefabs, Materials, Animatorcontrollers, Animations, and ScriptableObjects that reference said asset.

This was my approach because when I implemented something similar in Unity I found it to be unreliable at finding all the references. This may be tedious if looking for a large number of files, but in my experience it does find everything fairly reliably.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.