private static void OnProjectItemGUI(string guid, Rect position) { try { Profiler.BeginSample("Peek." + nameof(ProjectToolbars)); GuiCallback.Process(); var isList = position.height <= EditorGUIUtility.singleLineHeight; if (!isList) { return; } if (!PeekPlugin.Configuration.enableProjectToolbars) { return; } // Note: We can't properly handle sub-assets, because all we get is the GUID. var path = AssetDatabase.GUIDToAssetPath(guid); // Note: Force loading assets causes massive memory pressure on big projects if (!AssetDatabase.IsMainAssetAtPathLoaded(path)) { return; } position.xMin++; var fullRowPosition = position; fullRowPosition.xMax += 0; fullRowPosition.xMin -= 16; var target = AssetDatabase.LoadMainAssetAtPath(path); var isFocused = false; try { isFocused = ((EditorWindow)UnityEditorDynamic.ProjectBrowser.s_LastInteractedProjectBrowser).IsFocused(); } catch (Exception ex) { Debug.LogWarning($"Failed to determine if hierarchy window was focused:\n{ex}"); } TreeViewToolbars.OnItemGUI(toolbarControlProvider, target, position, fullRowPosition, isFocused); if (position.Contains(Event.current.mousePosition)) { EditorApplication.RepaintProjectWindow(); } } finally { Profiler.EndSample(); } }
private static void OnHierarchyItemGUI(int instanceID, Rect position) { GuiCallback.Process(); if (!PeekPlugin.Configuration.enableHierarchyToolbars) { return; } Profiler.BeginSample("Peek." + nameof(HierarchyToolbars)); var target = EditorUtility.InstanceIDToObject(instanceID); var fullRowPosition = position; fullRowPosition.xMax += 16; fullRowPosition.xMin -= 32; var isFocused = false; try { isFocused = UnityEditorDynamic.SceneHierarchyWindow.lastInteractedHierarchyWindow.sceneHierarchy.m_TreeView.HasFocus(); } catch (Exception ex) { Debug.LogWarning($"Failed to determine if hierarchy window was focused:\n{ex}"); } position.xMax -= Mathf.Abs(PeekPlugin.Configuration.hierarchyToolbarsOffset); TreeViewToolbars.OnItemGUI(toolbarControlProvider, target, position, fullRowPosition, isFocused); Profiler.EndSample(); if (fullRowPosition.Contains(Event.current.mousePosition)) { EditorApplication.RepaintHierarchyWindow(); } }