private void SetSelectionAndExpandedState(List <ISceneGraphNode> nodes) { var ids = AsInstanceIds(nodes.Select(n => n.Parent)) .Concat(nodes.Where(n => null == n.Parent).Select(n => n.Graph).OfType <SceneGraph>().Select(g => g.Scene.SceneGuid.GetHashCode())) .Distinct() .ToArray(); IdsToExpand.AddRange(ids); Selection.instanceIDs = AsInstanceIds(nodes).ToArray(); }
public void TransferSelection(List <Guid> guids) { var references = guids.Select(g => m_ComponentCache.GetEntityReference(g)).Where(r => r && null != r).ToList(); Selection.instanceIDs = references.Select(r => r.gameObject.GetInstanceID()).ToArray(); IdsToExpand.AddRange(references .Select(e => e.transform.parent) .Where(p => p && null != p) .Select(p => p.gameObject.GetInstanceID())); }
private DragAndDropVisualMode DoHandleSingleObjectDrop <TObject>(DragAndDropArgs args, TObject o, int offset) { var handler = HierarchyDragAndDrop <TObject, Key> .SingleObjectDrop; if (null == handler) { return(DragAndDropVisualMode.Rejected); } var item = GetDragAndDropItem(args); var result = DragAndDropVisualMode.Rejected; ISceneGraphNode resultNode = null; if (item is SceneItem sceneItem) { if (null != (resultNode = handler(m_Session, o, sceneItem.Graph, null, args.dragAndDropPosition == DragAndDropPosition.BetweenItems ? args.insertAtIndex : -1))) { IdsToExpand.Add(sceneItem.id); result = DragAndDropVisualMode.Link; } } if (item is EntityItem entityItem) { var node = entityItem.Node; if (null != (resultNode = handler(m_Session, o, node.Graph as SceneGraph, node, args.dragAndDropPosition == DragAndDropPosition.BetweenItems ? args.insertAtIndex : -1))) { IdsToExpand.Add(entityItem.id); result = DragAndDropVisualMode.Link; } } if (null == resultNode) { return(DragAndDropVisualMode.Rejected); } if (result == DragAndDropVisualMode.Link) { if (resultNode is EntityNode entityNode) { EntityHierarchyWindow.SelectOnNextPaint(entityNode.Guid); } } return(result); }
public override void OnGUI(Rect rect) { if (ShouldReload) { Reload(); } if (IdsToExpand.Count > 0) { ForceExpanded(IdsToExpand); IdsToExpand.Clear(); } base.OnGUI(rect); }