- Home /
Set Gizmo to object in editor by c# script
I create my own custom null-objects with my menu and I'd like to set Icon to it. It will be great if it possible to use custom images.
I suppose you're talking about specifically setting it in script, because obviously you can press the 'Other...' button to do it by hand.
I'd be interested in that aswell: is it possible to set the icon of a number of objects via script (e.g. i want 100 different objects to show those blue labels with their names on it in the scene view).
It may be possible if we had a list of the names of the default gizmo icons.
Was a solution discovered for this without the need to use the OnDrawGizmos function?
Answer by FatWednesday · Sep 07, 2012 at 11:24 PM
It is very possible indeed to have custom gizmo images. Import the image you want to use into your project. Then you want to add this function to your monobehaviour.
void OnDrawGizmos()
{
Gizmos.DrawIcon(transform.position, "YourImage.png", true);
}
Obviously you need to replace the image path with the path to your gizmo image relative to the assets folder. The boolean at the end flags weather or not the gizmo allows scaling (true for scaling in 3d, false for constant size).
hope this helps.
Your answer
