- Home /
Custom Inspector, Access built-in component icons?
Hi guys. I'm writing a custom inspector that overrides the default transform component inspector. It displays the components attached to the game object. I was wondering if anyone has come across a way to access Unity's built-in component 16x16 icons that displays next to the components name shown in the inspector? Ie, the C#, Js, rigidbody, collider, etc icons. Is there a way to access these internally, or, if that's not possible, can I locate them anywhere from the Unity installation? Thanks for your time,
Kind Regards, Sam
Answer by AndyGainey · Jan 23, 2016 at 01:28 AM
EditorGUIUtility.ObjectContent(Object obj, System.Type objType) did the trick for me. It returns a GUIContent instance with the image and text set appropriately, just as if you were using EditorGUI.ObjectField().
Answer by fafase · Mar 15, 2014 at 08:38 PM
Would that be what you are after?
http://answers.unity3d.com/questions/365137/how-to-change-component-icon-shown.html
EDIT: Accroding to the link below, it can only be done via inspector and not at runtime http://answers.unity3d.com/questions/7983/changing-the-inspector-titlebar-icon-and-text.html
EDIT AGAIN: If you open a meta file from a script it will display what is the icon. Problem it is an information that you cannot really use as it looks like this:
fileFormatVersion: 2
guid: edaad01d80168b44da722af7b39bfc7b
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: -1376725286, guid: 0000000000000000d000000000000000, type: 0}
userData:
If the default is used you get :
icon: {instanceID: 0 }
Thats similar to what I'm after, but I don't need to change them, I need a way to access those icons from script to display them elsewhere :)
Was there ever a solution found for this? I'm trying to do the same thing.
Currently, my only solution is to take a screen cap of the pre-defined icons and save them as a png in the Gizmos folder. It works, but not the most elegant solution.