Set inspector icon for GameObjects via C# script in Unity
Ever wondered how you can set the inspector icon for GameObjects via a C# script in Unity? Especially without reflection, which is the old solution to do.
Execute this in an editor script:
var iconContent = EditorGUIUtility.IconContent("sv_label_1");
EditorGUIUtility.SetIconForObject(gameObject, (Texture2D) iconContent.image);
sv_label_1
is the blue rounded rectangle. For other icons, see this nice list of all Unity built-in editor icons: https://github.com/halak/unity-editor-icons