internal static void DoObjectPingField(Rect position, Rect dropRect, int id, Object obj, Type objType)
{
Event current = Event.current;
EventType rawType = current.type;
if ((!GUI.enabled && GUIClip.enabled) && (Event.current.rawType == EventType.MouseDown))
{
rawType = Event.current.rawType;
}
bool flag = EditorGUIUtility.HasObjectThumbnail(objType) && (position.height > 16f);
switch (rawType)
{
case EventType.MouseDown:
if ((Event.current.button == 0) && position.Contains(Event.current.mousePosition))
{
Object gameObject = obj;
Component component = gameObject as Component;
if (component != null)
{
gameObject = component.gameObject;
}
if (Event.current.clickCount == 1)
{
GUIUtility.keyboardControl = id;
if (gameObject != null)
{
EditorGUIUtility.PingObject(gameObject);
}
current.Use();
}
else if (Event.current.clickCount == 2)
{
if (gameObject != null)
{
AssetDatabase.OpenAsset(gameObject);
GUIUtility.ExitGUI();
}
current.Use();
}
}
break;
case EventType.Repaint:
{
GUIContent content = EditorGUIUtility.ObjectContent(obj, objType);
if (flag)
{
GUIStyle objectFieldThumb = EditorStyles.objectFieldThumb;
objectFieldThumb.Draw(position, GUIContent.none, id, DragAndDrop.activeControlID == id);
if (obj != null)
{
EditorGUI.DrawPreviewTexture(objectFieldThumb.padding.Remove(position), content.image);
}
else
{
(objectFieldThumb.name + "Overlay").Draw(position, content, id);
}
}
else
{
EditorStyles.objectField.Draw(position, content, id, DragAndDrop.activeControlID == id);
}
break;
}
}
}