private void Reselect(AssetChanges changes) { s_LastInfo = null; SelectionChanged(m_SelectedObjects, true); }
private void SelectionChanged(Object[] selection, bool force) { Object[] oldSelection = m_SelectedObjects; // We don't need to update if the selection is null. Just clear m_LastInfo in case it's set. if (selection == null || selection.Length == 0) { return; } Object[] projectAssets = selection.Select(GetRootObject).Where(o => o).Distinct().ToArray(); if (projectAssets.Length == 0) { return; } if (!m_LockSelection || m_SelectedObjects == null || m_SelectedObjects.Length == 0) { m_SelectedObjects = projectAssets; } // If we haven't changed selections, skip it. if (!force && s_LastInfo != null && s_LastInfo.Targets.IsEqual(m_SelectedObjects)) { return; } // Only update the flow stack if the selection has changed. if (!oldSelection.IsEqual(m_SelectedObjects)) { Object[] prev = m_GoBackStack.LastOrDefault(); Object[] next = m_GoForwardStack.LastOrDefault(); if (prev != null && prev.Length > 0 && prev.IsEqual(m_SelectedObjects)) { // If the previous item is the new selection, then go 'back' by removing 'prev' and adding old selection to forward stack. Pop(m_GoBackStack); if (oldSelection != null) { m_GoForwardStack.Add(oldSelection); } } else if (next != null && next.Length > 0 && next.IsEqual(m_SelectedObjects)) { // If the next item is the new select, then go 'forward' by removing 'next' and adding old selection to back stack. Pop(m_GoForwardStack); if (oldSelection != null) { m_GoBackStack.Add(oldSelection); } } else { // Otherwise, this is just a new selection, to put the old one in the back. if (oldSelection != null) { m_GoBackStack.Add(oldSelection); } m_GoForwardStack.Clear(); } } s_LastInfo = GetUsageInfo(m_SelectedObjects); EditorApplication.delayCall += Repaint; }