public static void DoAnnotationGUI(int id, Rect rect) { var obj = EditorUtility.InstanceIDToObject(id) as GameObject; if (!obj) { return; } var tc = obj.GetComponent <TestComponent>(); if (!tc) { return; } if (!EditorApplication.isPlayingOrWillChangePlaymode && rect.Contains(Event.current.mousePosition) && Event.current.type == EventType.MouseDown && Event.current.button == 1) { IntegrationTestRendererBase.DrawContextMenu(tc); Event.current.Use(); } EditorGUIUtility.SetIconSize(new Vector2(15, 15)); var result = IntegrationTestsRunnerWindow.GetResultForTest(tc); if (result != null) { var icon = result.Executed ? IntegrationTestRendererBase.GetIconForResult(result.resultType) : Icons.UnknownImg; EditorGUI.LabelField(new Rect(rect.xMax - 18, rect.yMin - 2, rect.width, rect.height), new GUIContent(icon)); } EditorGUIUtility.SetIconSize(Vector2.zero); }
public static void OnHierarchyWindowItemDraw(int id, Rect rect) { var o = EditorUtility.InstanceIDToObject(id); if (o is GameObject) { var go = o as GameObject; var tc = go.GetComponent <TestComponent>(); if (tc != null) { if (!EditorApplication.isPlayingOrWillChangePlaymode && rect.Contains(Event.current.mousePosition) && Event.current.type == EventType.MouseDown && Event.current.button == 1) { IntegrationTestRendererBase.DrawContextMenu(tc); } EditorGUIUtility.SetIconSize(new Vector2(15, 15)); var result = s_Instance.m_ResultList.Find(r => r.GameObject == go); if (result != null) { var icon = result.Executed ? IntegrationTestRendererBase.GetIconForResult(result.resultType) : Icons.UnknownImg; EditorGUI.LabelField(new Rect(rect.xMax - 18, rect.yMin - 2, rect.width, rect.height), new GUIContent(icon)); } EditorGUIUtility.SetIconSize(Vector2.zero); } if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && rect.Contains(Event.current.mousePosition)) { var temp = go.transform; while (temp != null) { var c = temp.GetComponent <TestComponent>(); if (c != null) { break; } temp = temp.parent; } if (temp != null) { SelectInHierarchy(temp.gameObject); } } } }