Finding filenames from a GameObject

Hello, I’m currently working on an asset management system, and need to get the names of the assets from GameObjects in the heirarchy.

In other words, I have a GameObject created from a model, texture, some audio files, etc. and I would like to figure out what file corresponds to what, working backward from the GameObject.

This must be possible, since Unity can show me directly (clicking on the component will highlight the file in project view) but I can’t seem to find out how to script it.

I’ve looked into the AssetDatabase.GetAssetPath() function, but AD.Contains returns false on the various components. Here’s what I’ve tried:

AssetDatabase.Contains(g.GetComponent().mesh)
AssetDatabase.Contains(g.renderer.material.mainTexture)

Any ideas?

Actually nevermind. I was doing it on the wrong object :smile: