private static void     UpdateSelection()
        {
            int hash = NGNavSelectionWindow.GetCurrentSelectionHash();

            if (NGNavSelectionWindow.lastHash == hash || hash == 0)
            {
                return;
            }

            if (Selection.objects.Length > 0)
            {
                // Prevent adding a new selection if the user just selected it through NG Nav Selection.
                if (0 <= NGNavSelectionWindow.lastFocusedHistoric && NGNavSelectionWindow.lastFocusedHistoric < NGNavSelectionWindow.historic.Count && NGNavSelectionWindow.historic[NGNavSelectionWindow.lastFocusedHistoric].GetSelectionHash() == hash)
                {
                    return;
                }

                NGNavSelectionWindow.hasChanged = true;

                // Add a new selection or update the last one.
                if (NGNavSelectionWindow.historicCursor != -1)
                {
                    NGNavSelectionWindow.historic.RemoveRange(NGNavSelectionWindow.historicCursor + 1, NGNavSelectionWindow.historic.Count - NGNavSelectionWindow.historicCursor - 1);
                    NGNavSelectionWindow.historicCursor = -1;
                }

                // Detect a change in the selection only if user selects ONE Object.
                if (Selection.objects.Length == 1)
                {
                    NGNavSelectionWindow.historic.Add(new AssetsSelection(Selection.objects, Selection.instanceIDs));
                }
                else if (NGNavSelectionWindow.historic.Count >= 1)
                {
                    NGNavSelectionWindow.historic[NGNavSelectionWindow.historic.Count - 1] = new AssetsSelection(Selection.objects, Selection.instanceIDs);
                }

                NavSettings settings = HQ.Settings.Get <NavSettings>();

                if (settings.maxHistoric > 0 && NGNavSelectionWindow.historic.Count > settings.maxHistoric)
                {
                    NGNavSelectionWindow.historic.RemoveRange(0, NGNavSelectionWindow.historic.Count - settings.maxHistoric);
                }
            }
            else
            {
                NGNavSelectionWindow.historicCursor = -1;
            }

            NGNavSelectionWindow.lastFocusedHistoric = -1;

            NGNavSelectionWindow.lastHash = hash;
            if (NGNavSelectionWindow.SelectionChanged != null)
            {
                NGNavSelectionWindow.SelectionChanged();
            }
        }
        public static void      SelectPreviousSelection()
        {
            if (NGNavSelectionWindow.historicCursor == 0)
            {
                return;
            }

            do
            {
                if (NGNavSelectionWindow.historicCursor == -1 && NGNavSelectionWindow.historic.Count >= 2)
                {
                    if (Selection.activeInstanceID == 0)
                    {
                        NGNavSelectionWindow.historicCursor = NGNavSelectionWindow.historic.Count - 1;
                    }
                    else
                    {
                        NGNavSelectionWindow.historicCursor = NGNavSelectionWindow.historic.Count - 2;
                    }
                    NGNavSelectionWindow.lastHash = NGNavSelectionWindow.historic[NGNavSelectionWindow.historicCursor].GetSelectionHash();
                }
                else if (NGNavSelectionWindow.historicCursor > 0)
                {
                    --NGNavSelectionWindow.historicCursor;
                    NGNavSelectionWindow.lastHash = NGNavSelectionWindow.historic[NGNavSelectionWindow.historicCursor].GetSelectionHash();

                    if (NGNavSelectionWindow.historicCursor == 0 && NGNavSelectionWindow.lastHash == 0)
                    {
                        break;
                    }
                }
                else
                {
                    break;
                }
            }while (NGNavSelectionWindow.lastHash == 0);

            if (0 <= NGNavSelectionWindow.historicCursor &&
                NGNavSelectionWindow.historicCursor < NGNavSelectionWindow.historic.Count)
            {
                NGNavSelectionWindow.historic[NGNavSelectionWindow.historicCursor].Select();
                NGNavSelectionWindow.lastFocusedHistoric = -1;
                if (NGNavSelectionWindow.SelectionChanged != null)
                {
                    NGNavSelectionWindow.SelectionChanged();
                }
            }
        }
        public static void      SelectNextSelection()
        {
            int lastNotNullSelection = NGNavSelectionWindow.historicCursor;

            do
            {
                if (NGNavSelectionWindow.historicCursor >= 0 && NGNavSelectionWindow.historicCursor < NGNavSelectionWindow.historic.Count - 1)
                {
                    ++NGNavSelectionWindow.historicCursor;
                    NGNavSelectionWindow.lastHash = NGNavSelectionWindow.historic[NGNavSelectionWindow.historicCursor].GetSelectionHash();
                    if (NGNavSelectionWindow.lastHash != 0)
                    {
                        lastNotNullSelection = NGNavSelectionWindow.historicCursor;
                    }

                    if (NGNavSelectionWindow.historicCursor >= NGNavSelectionWindow.historic.Count - 1)
                    {
                        NGNavSelectionWindow.historicCursor = -1;
                    }
                }
                else
                {
                    break;
                }
            }while (NGNavSelectionWindow.lastHash == 0);

            if (0 <= lastNotNullSelection &&
                lastNotNullSelection < NGNavSelectionWindow.historic.Count)
            {
                NGNavSelectionWindow.historic[lastNotNullSelection].Select();
                NGNavSelectionWindow.lastFocusedHistoric = -1;
                if (NGNavSelectionWindow.SelectionChanged != null)
                {
                    NGNavSelectionWindow.SelectionChanged();
                }
            }
            else if (lastNotNullSelection != -1)
            {
                NGNavSelectionWindow.historic[NGNavSelectionWindow.historic.Count - 1].Select();
                NGNavSelectionWindow.lastFocusedHistoric = -1;
                if (NGNavSelectionWindow.SelectionChanged != null)
                {
                    NGNavSelectionWindow.SelectionChanged();
                }
            }
        }