Skip to content

Instantly share code, notes, and snippets.

@baba-s
Created July 7, 2021 02:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baba-s/375f4fa8eda7b0480513983ed2599dd7 to your computer and use it in GitHub Desktop.
Save baba-s/375f4fa8eda7b0480513983ed2599dd7 to your computer and use it in GitHub Desktop.
using Kogane;
using UnityEditor;
using UnityEngine;
[InitializeOnLoad]
internal static class Example
{
private const float SIZE = 20;
private const string NAME = "d_console.warnicon";
private static GUIContent m_icon;
static Example()
{
EditorApplication.hierarchyWindowItemOnGUI += OnGUI;
}
private static void OnGUI( int instanceID, Rect rect )
{
var gameObject = EditorUtility.InstanceIDToObject( instanceID ) as GameObject;
if ( gameObject == null ) return;
var hasMissingReference = MissingReferenceUtils.HasMissingReference( gameObject );
if ( !hasMissingReference ) return;
rect.x += rect.width - 2;
rect.y -= 2;
rect.width = SIZE;
rect.height = SIZE;
if ( m_icon == null )
{
m_icon = EditorGUIUtility.IconContent( NAME );
}
GUI.Label( rect, m_icon );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment