A static class for interacting with the Scene View icons and gizmos for types.
using System; using UnityEditor; using UnityEngine; // An Editor Window that lets you edit the gizmo and icon properties for each selected component. public class GizmoUtilityExample : EditorWindow { [MenuItem("Window/Gizmo Window")] static void Init() => GetWindow<GizmoUtilityExample>(); Vector2 m_Scroll; void OnEnable() { autoRepaintOnSceneChange = true; } void OnGUI() { GizmoUtility.use3dIcons = EditorGUILayout.Toggle("3D Icons", GizmoUtility.use3dIcons); EditorGUI.BeginDisabled(!GizmoUtility.use3dIcons); GizmoUtility.iconSize = EditorGUILayout.Slider("3D Icon Size", GizmoUtility.iconSize, 0f, 1f); EditorGUI.EndDisabled(); m_Scroll = EditorGUILayout.BeginScrollView(m_Scroll); foreach (var go in Selection.gameObjects) { GUILayout.Label($"{go.name} Gizmos", EditorStyles.boldLabel); EditorGUI.indentLevel++; foreach (var component in go.GetComponents<Component>()) { // A component can have gizmos, an icon, both, or neither. A gizmo can also be disabled (the Editor // is collapsed in the Inspector). if (GizmoUtility.TryGetGizmoInfo(component.GetType(), out GizmoInfo info)) { EditorGUI.BeginChangeCheck(); if (info.hasGizmo) info.gizmoEnabled = EditorGUILayout.Toggle($"{info.name} Gizmo", info.gizmoEnabled); if (info.hasIcon) info.iconEnabled = EditorGUILayout.Toggle($"{info.name} Icon", info.iconEnabled); if (EditorGUI.EndChangeCheck()) GizmoUtility.ApplyGizmoInfo(info); } } EditorGUI.indentLevel--; } EditorGUILayout.EndScrollView(); } }
iconSize | Control the size that 3D icons render in the Scene View. |
use3dIcons | Determines whether icons in the Scene View are a fixed size (false) or scaled relative to distance from the camera and iconSize. |
ApplyGizmoInfo | Apply [[GizmoInfo::gizmoEnabled]] and [[GizmoInfo::iconEnabled]] for a GizmoInfo object. |
GetGizmoInfo | Get GizmoInfo for all components with gizmos or icons in the project. |
SetGizmoEnabled | Enable or disable gizmo rendering in the Scene View for a component type. Gizmos are the simple lines and guides drawn by component editors. For example, the Camera frustum guidelines are gizmos. |
SetIconEnabled | Enable or disable icon rendering for all objects in the Scene View for a component type. |
TryGetGizmoInfo | Get a GizmoInfo for a type if it exists. |
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.