- Home /
Getting Prefab Icon from AssetDatabase
I noticed that the AssetDatabse automatically generate realistic icons for prefabs etc, and when you select objects to assign to things, you see an actual picture of the prefab. But if you use:
var icon1 : Texture2D = AssetDatabase.GetCachedIcon("Assets/Buildings/Assembly1.prefab");
you just get the basic little blue cube from the editor. Anyone know a way to get the 'real' icon that looks like the actual prefab? It would be awesome to dynamically grab them for buttons etc.
The picture you see of the prefab isn't an icon, it's actually rendering the object! I'm not sure if you can get a still image of that automatically, because it's dependent on a camera angle of some kind.
Ok thanks for the quick reply - I was afraid of that. I also tried:
'EditorGUIUtility.ObjectContent(x,GameObject).image)'
which runs without erroring, but no picture is generated, although I can get the GameObject name from it. Thanks.
You don't. Sorry, I didn't think my comment warranted an answer... You can turn your solution into an answer and post that yourself, then mark that as the accepted one.