Esempio n. 1
0
        public override void    OnGUI()
        {
            if (this.buttonLeft == null)
            {
                this.buttonLeft  = "ButtonLeft";
                this.buttonRight = "ButtonRight";
            }

            EditorGUI.BeginDisabledGroup(!NGNavSelectionWindow.CanSelectPrevious);
            {
                if (GUILayout.Button(this.leftContent, this.buttonLeft, GUILayoutOptionPool.Height(this.hub.height)) == true)
                {
                    NGNavSelectionWindow.SelectPreviousSelection();
                }
            }
            EditorGUI.EndDisabledGroup();

            EditorGUI.BeginDisabledGroup(!NGNavSelectionWindow.CanSelectNext);
            {
                if (GUILayout.Button(this.rightContent, this.buttonRight, GUILayoutOptionPool.Height(this.hub.height)) == true)
                {
                    NGNavSelectionWindow.SelectNextSelection();
                }
            }
            EditorGUI.EndDisabledGroup();
        }
Esempio n. 2
0
        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();
            }
        }
Esempio n. 3
0
        public static void      SetHistoricCursor(int i)
        {
            NGNavSelectionWindow.historicCursor = i;

            if (i >= 0)
            {
                NGNavSelectionWindow.historic[NGNavSelectionWindow.historicCursor].Select();
                NGNavSelectionWindow.lastHash = NGNavSelectionWindow.GetCurrentSelectionHash();
            }
        }
Esempio n. 4
0
        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();
                }
            }
        }
Esempio n. 5
0
        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();
                }
            }
        }
Esempio n. 6
0
        private static void     OnPlayStateChanged(
#if UNITY_2017_2_OR_NEWER
            PlayModeStateChange state
#endif
            )
        {
            if (NGNavSelectionWindow.isPlaging == true && EditorApplication.isPlayingOrWillChangePlaymode == false)
            {
                NGNavSelectionWindow.isPlaging = false;
                NGNavSelectionWindow.SaveHistoric();
            }
            else if (EditorApplication.isCompiling == true && NGNavSelectionWindow.savedOnCompile == false)
            {
                NGNavSelectionWindow.savedOnCompile = true;
                NGNavSelectionWindow.SaveHistoric();
            }
        }
Esempio n. 7
0
        private static void     HandleMouseInputs()
        {
            if (EditorApplication.isCompiling == true)
            {
                if (NGNavSelectionWindow.savedOnCompile == false)
                {
                    NGNavSelectionWindow.savedOnCompile = true;
                    NGNavSelectionWindow.SaveHistoric();
                }

                return;
            }

            IntPtr activeWindow = NativeMethods.GetActiveWindow();

            if (activeWindow != IntPtr.Zero)
            {
                // Go to previous selection.
                if (NativeMethods.GetAsyncKeyState(5) != 0)
                {
                    if (NGNavSelectionWindow.buttonWasDown == false)
                    {
                        NGNavSelectionWindow.buttonWasDown = true;
                        NGNavSelectionWindow.SelectPreviousSelection();
                    }
                }
                // Go to next selection.
                else if (NativeMethods.GetAsyncKeyState(6) != 0)
                {
                    if (NGNavSelectionWindow.buttonWasDown == false)
                    {
                        NGNavSelectionWindow.buttonWasDown = true;
                        NGNavSelectionWindow.SelectNextSelection();
                    }
                }
                else
                {
                    NGNavSelectionWindow.buttonWasDown = false;
                }
            }
        }