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 Replace(MenuCommand menuCommand) { var targets = GetTargets(menuCommand); if (enqueuedMultiTargetsCommand) { return; } enqueuedMultiTargetsCommand = true; GuiCallback.Enqueue(() => { GameObjectOperations.Replace(targets, activatorPosition); enqueuedMultiTargetsCommand = false; }); }
private static void OnSceneGUI(SceneView sceneView) { GuiCallback.Process(); used = false; Tabs.OnSceneGUI(sceneView); SceneToolbars.OnSceneGUI(sceneView); Probe.OnSceneGUI(sceneView); Creator.OnSceneGUI(sceneView); SceneMaximizerIntegration.OnSceneGUI(sceneView); SceneDeselectIntegration.OnSceneGUI(sceneView); SceneHierarchyIntegration.OnSceneGUI(sceneView); }
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(); } }
private static void OnSceneGUI(SceneView sceneView) { GuiCallback.Process(); used = false; // Optim: we don't care about MouseMove because we get constant Repaint anyway if (Event.current.type == EventType.MouseMove) { return; } // Optim: we don't use Layout, skip for another massive boost if (Event.current.type == EventType.Layout) { // TODO: We can't do this optims because the fact that we call GetControlID in // ToolControl.DropdownToggle offsets the IDs across events and thus // breaks the handles. We'd need to do like in Bolt, AKA fetch all the CIDs // on all events, but don't render anything after that. // return; } Tabs.OnSceneGUI(sceneView); SceneToolbars.OnSceneGUI(sceneView); Probe.OnSceneGUI(sceneView); Creator.OnSceneGUI(sceneView); SceneMaximizerIntegration.OnSceneGUI(sceneView); SceneDeselectIntegration.OnSceneGUI(sceneView); SceneHierarchyIntegration.OnSceneGUI(sceneView); }
private static void CenterOnBounds(MenuCommand menuCommand) { var target = GetTarget(menuCommand); GuiCallback.Enqueue(() => { TransformOperations.CenterOnBounds(target); }); }
private static void Bake(MenuCommand menuCommand) { var target = GetTarget(menuCommand); GuiCallback.Enqueue(() => { TransformOperations.Bake(target); }); }
private static void CreateChild(MenuCommand menuCommand) { var target = GetTarget(menuCommand); GuiCallback.Enqueue(() => { GameObjectOperations.CreateChild(target, activatorPosition); }); }
private static void CreatePrefab(MenuCommand menuCommand) { var target = GetTarget(menuCommand); GuiCallback.Enqueue(() => { GameObjectOperations.CreatePrefab(target); }); }
private static void Replace(MenuCommand menuCommand) { var targets = GetTargets(menuCommand); GuiCallback.Enqueue(() => { GameObjectOperations.Replace(targets, activatorPosition); }); }