Exemplo n.º 1
0
        private static void CatchGlobalKeyEvents(Event current)
        {
            if (current.type != EventType.KeyUp)
            {
                return;
            }
            ModifierKey modifier    = ExtShortCutEditor.GetModifierKey(UnityEssentialsPreferences.SHORTCUT_MODIFIER_KEY_FOR_PREVIOUS_NEXT_SELECTION, (int)UnityEssentialsPreferences.DEFAULT_MODIFIER_KEY);
            KeyCode     previousKey = ExtShortCutEditor.GetKey(UnityEssentialsPreferences.SHORTCUT_KEY_FOR_PREVIOUS_SELECTION, (int)UnityEssentialsPreferences.DEFAULT_PREVIOUS_KEY);
            KeyCode     nextKey     = ExtShortCutEditor.GetKey(UnityEssentialsPreferences.SHORTCUT_KEY_FOR_NEXT_SELECTION, (int)UnityEssentialsPreferences.DEFAULT_NEXT_KEY);

            bool shortCutPrevious = ExtShortCutEditor.IsModifierEnumMatch(Event.current, modifier) && current.keyCode == previousKey;
            bool shortCutNext     = ExtShortCutEditor.IsModifierEnumMatch(Event.current, modifier) && current.keyCode == nextKey;

            if (shortCutPrevious)
            {
                if (Selection.objects.Length != 0)
                {
                    AddToIndex(-1);
                }
                ForceSelection(PeekSerializeObject.SelectedObjectsIndex(PeekSerializeObject.CurrentIndex));
            }
            else if (shortCutNext)
            {
                AddToIndex(1);
                ForceSelection(PeekSerializeObject.SelectedObjectsIndex(PeekSerializeObject.CurrentIndex));
            }
        }
Exemplo n.º 2
0
        public static void ForceSelection(UnityEngine.Object forcedSelection, bool select = true, bool showNameInSceneView = true, bool canDoubleClic = false)
        {
            bool doubleClic = PeekSerializeObject.LastSelectedObject == forcedSelection;

            PeekSerializeObject.ChangeLastSelectedObject(forcedSelection);
            PeekSerializeObject.Save(30);

            if (select)
            {
                Selection.activeObject = PeekSerializeObject.LastSelectedObject;
                EditorGUIUtility.PingObject(PeekSerializeObject.LastSelectedObject);
            }
            else
            {
                EditorGUIUtility.PingObject(PeekSerializeObject.LastSelectedObject);
            }
            if (showNameInSceneView)
            {
                //ShaderOutline.ShaderOutline.SelectionChangedByPreviousNext();
            }
            if (canDoubleClic && doubleClic)
            {
                SceneView.FrameLastActiveSceneView();
            }
        }
Exemplo n.º 3
0
        private static void UpdateEditor()
        {
            try
            {
                WaitUntilSceneIsValid();

                UnityEngine.Object currentSelectedObject = Selection.activeObject;

                if (currentSelectedObject != null &&
                    currentSelectedObject != PeekSerializeObject.LastSelectedObject &&
                    currentSelectedObject.GetType().ToString() != "Search.Pro.InspectorRecentSO")
                {
                    AttemptToRemoveNull();
                    if (PeekSerializeObject.AddNewSelection(currentSelectedObject))
                    {
                        PeekSerializeObject.Save();
                    }
                }

                if (!_isInit)
                {
                    Init();
                }
                if (_isClosed != IsEditorWindowLinked)
                {
                    SaveCloseStatus();
                    _isClosed = IsEditorWindowLinked;
                }
            }
            catch { }
        }
Exemplo n.º 4
0
 private static void AttemptToRemoveNull()
 {
     if (PeekSerializeObject.SelectedObjectsList != null && PeekSerializeObject.SelectedObjectsList.IsThereNullCustomObjectInList())
     {
         PeekSerializeObject.AttemptToRemoveNull();
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// add a given Object into bookmark
 /// </summary>
 /// <param name="toSave"></param>
 /// <returns></returns>
 public static bool AddToBookMark(UnityEngine.Object toSave)
 {
     PeekSerializeObject.AddNewBookMark(toSave);
     PeekSerializeObject.RemoveSelectedWithoutDuplicate(toSave);
     PeekSerializeObject.Save();
     return(true);
 }
 public static void ClearSelectedList()
 {
     if (SelectedObjectsWithoutDuplicateList.ContainsObject(LastSelectedObject))
     {
         PeekSerializeObject.ChangeLastSelectedObject(null);
     }
     SelectedObjectsWithoutDuplicateList.ClearArray();
     Save();
 }
 public static void ClearBookMarkAsset()
 {
     if (PinnedObjectsList.ContainsObject(LastSelectedObject))
     {
         PeekSerializeObject.ChangeLastSelectedObject(null);
     }
     PinnedObjectsList.ClearArray();
     Save();
 }
Exemplo n.º 8
0
        public static void UpdateSceneGameObjectOnLoad()
        {
            int countScene = SceneManager.sceneCount;

            for (int i = 0; i < countScene; i++)
            {
                Scene scene = SceneManager.GetSceneAt(i);
                _sceneLoaded.AddIfNotContain(scene);
            }
            PeekSerializeObject.DeleteBookMarkedGameObjectOfLostScene();
        }
        public static void ClearBookMarkGameObjects()
        {
            if (PinnedObjectsInScenesList.ContainsObject(LastSelectedObject))
            {
                PeekSerializeObject.ChangeLastSelectedObject(null);
            }

            PinnedObjectsInScenesList.ClearArray();
            PinnedObjectsNameInScenesList.ClearArray();
            PinnedObjectsScenesLinkList.ClearArray();
            Save();
        }
        public static void RemoveBookMarkedItem(int index)
        {
            if (LastSelectedObject == PinnedObjectsInScenesIndex(index))
            {
                PeekSerializeObject.ChangeLastSelectedObject(null);
            }
            SelectedObjectsList.RemoveAllObject(PinnedObjectsIndex(index));
            SelectedObjectsWithoutDuplicateList.RemoveObject(PinnedObjectsIndex(index));
            PinnedObjectsList.RemoveAt(index);

            Save();
        }
Exemplo n.º 11
0
 public static bool AddSelectionToBookMark()
 {
     for (int i = 0; i < Selection.objects.Length; i++)
     {
         if (Selection.objects[i] != null)
         {
             PeekSerializeObject.AddNewBookMark(Selection.objects[i]);
             PeekSerializeObject.RemoveSelectedWithoutDuplicate(Selection.objects[i]);
             PeekSerializeObject.Save(1f);
         }
     }
     return(true);
 }
Exemplo n.º 12
0
        /// <summary>
        /// Attempt to relink all gameObject
        /// with bookMarks with by their [Scene name + name]
        ///
        /// Do a deep clean of list before!
        /// </summary>
        /// <param name="foundObjects"></param>
        public void RelinkNamesWithGameObjects(List <Transform> foundObjects)
        {
            if (foundObjects == null || PeekSaveDatas.Instance == null)
            {
                return;
            }
            CleanArraysFromDuplicateInNameAndObjectReferences(
                PeekSerializeObject.PeekSave.GetPropertie("_pinnedObjectsInScenes"),
                PeekSerializeObject.PeekSave.GetPropertie("_pinnedObjectsNameInScenes"),
                PeekSerializeObject.PeekSave.GetPropertie("_pinnedObjectsScenesLink"));

            for (int i = 0; i < PeekSerializeObject.PinnedObjectsInScenesCount; i++)
            {
                if (PeekSerializeObject.PinnedObjectsInScenesIndex(i) == null)
                {
                    for (int k = 0; k < foundObjects.Count; k++)
                    {
                        GameObject foundGameObject = foundObjects[k].gameObject;
                        if (string.Equals(
                                PeekSerializeObject.PinnedObjectsScenesLinkIndex(i).name + "/" + PeekSerializeObject.PinnedObjectsNameInScenesIndex(i),
                                foundGameObject.scene.name + "/" + foundGameObject.name))
                        {
                            PeekSerializeObject.PinnedObjectsInScenesList.GetArrayElementAtIndex(i).SetCustomObject(foundGameObject);
                            if (_mustSearchForGameObject &&
                                string.Equals(foundGameObject.scene.name, _sceneNameOfGameObjectToSelect) &&
                                string.Equals(foundGameObject.name, _gameObjectNametoSelect))
                            {
                                _mustSearchForGameObject = false;
                                PeekLogic.ForceSelection(foundGameObject);
                                SceneView.FrameLastActiveSceneView();
                            }
                        }
                    }
                }
            }
            PeekSerializeObject.Save(1f);
        }
Exemplo n.º 13
0
 private void OnSelectedObjectPinned(int index)
 {
     SelectItem(PeekSerializeObject.SelectedObjectsWithoutDuplicateIndex(index), false);
 }
Exemplo n.º 14
0
 private void OnSelectedObjectBookMarkClicked(int index)
 {
     PeekLogic.SaveToBookMark(PeekSerializeObject.SelectedObjectsWithoutDuplicateIndex(index), index);
 }
Exemplo n.º 15
0
 private void OnSelectedObjectClicked(int index)
 {
     SelectItem(PeekSerializeObject.SelectedObjectsWithoutDuplicateIndex(index));
 }
Exemplo n.º 16
0
 private void OnPinnedObjectRemove(int index)
 {
     PeekSerializeObject.RemoveBookMarkedItem(index);
 }
Exemplo n.º 17
0
 private void OnPinnedObjectListClear()
 {
     PeekSerializeObject.ClearBookMarkAsset();
 }
Exemplo n.º 18
0
 public static void SaveToBookMark(UnityEngine.Object toSelect, int index)
 {
     PeekSerializeObject.AddNewBookMark(toSelect);
     PeekSerializeObject.RemoveSelectedWithoutDuplicateAt(index);
     PeekSerializeObject.Save();
 }
Exemplo n.º 19
0
 private void OnPinnedObjectPinned(int index)
 {
     SelectItem(PeekSerializeObject.PinnedObjectsIndex(index), false);
 }
Exemplo n.º 20
0
 private void OnPinnedSceneGameObjectListClear()
 {
     PeekSerializeObject.ClearBookMarkGameObjects();
 }
Exemplo n.º 21
0
 private void OnPinnedObjectBookMarkClicked(int index)
 {
     PeekSerializeObject.RemoveAssetFromBookMark(index);
 }
Exemplo n.º 22
0
 private void OnPinnedSceneGameObjectInfo(int index)
 {
     SelectItem(PeekSerializeObject.PinnedObjectsScenesLinkIndex(index));
 }
Exemplo n.º 23
0
 private void OnPinnedSceneGameObjectInfoOpenScene(int index)
 {
     PeekLogic.SwapSceneAndSelectItem(PeekSerializeObject.PinnedObjectsScenesLinkIndex(index).GetPath(), PeekSerializeObject.PinnedObjectsNameInScenesIndex(index), PeekSerializeObject.PinnedObjectsScenesLinkIndex(index).name);
 }
Exemplo n.º 24
0
 private void OnPinnedSceneGameObjectBookMarkClicked(int index)
 {
     PeekSerializeObject.MoveToBookMark(index);
 }
Exemplo n.º 25
0
 public static void DeleteBookMarkedGameObjectLinkedToScene()
 {
     PeekSerializeObject.DeleteBookMarkedGameObjectOfLostScene();
 }
Exemplo n.º 26
0
        /// <summary>
        /// display the content of the peek toolBar
        /// </summary>
        public bool DisplayPeekToolBar()
        {
            if (PeekSaveDatas.Instance == null)
            {
                return(false);
            }

            if (PeekSerializeObject.CurrentIndex >= PeekSerializeObject.SelectedObjectsCount)
            {
                PeekSerializeObject.SetCurrentIndex(PeekSerializeObject.SelectedObjectsCount - 1);
                PeekSerializeObject.Save(30);
            }

            using (VerticalScope vertical = new VerticalScope())
            {
                GUILayout.Label("Browse selections", ExtGUIStyles.MiniTextCentered, GUILayout.Height(_heightText));
                using (HorizontalScope horizontal = new HorizontalScope())
                {
                    if (GUILayout.Button(EditorGUIUtility.IconContent(OPEN_EDITOR_WINDOW_ICON), ExtGUIStyles.MicroButton, GUILayout.Width(28), GUILayout.Height(EditorGUIUtility.singleLineHeight)) && Event.current.button == 0)
                    {
                        PeekLogic.ManageOpenPeekEditorWindow();
                    }
#if UNITY_2018_3_OR_NEWER
                    if (IsRightClickContext())
                    {
                        return(true);
                    }
#endif


                    EditorGUI.BeginDisabledGroup(PeekSerializeObject.SelectedObjectsCount == 0);
                    {
                        float         delta           = 0;
                        bool          isScrollingDown = ExtMouse.IsScrollingDown(Event.current, ref delta);
                        StringBuilder previousTip     = new StringBuilder();
                        previousTip.Append("Go to previous selection (");
                        previousTip.Append(ExtShortCutEditor.GetModifierKey(UnityEssentialsPreferences.SHORTCUT_MODIFIER_KEY_FOR_PREVIOUS_NEXT_SELECTION, (int)UnityEssentialsPreferences.DEFAULT_MODIFIER_KEY));
                        previousTip.Append("+");
                        previousTip.Append(ExtShortCutEditor.GetKey(UnityEssentialsPreferences.SHORTCUT_KEY_FOR_PREVIOUS_SELECTION, (int)UnityEssentialsPreferences.DEFAULT_PREVIOUS_KEY));
                        previousTip.Append(")");

                        if ((GUILayout.Button(new GUIContent(PREVIOUS_ICON, previousTip.ToString()), ExtGUIStyles.MicroButton, GUILayout.Width(23), GUILayout.Height(EditorGUIUtility.singleLineHeight)) && Event.current.button == 0) || isScrollingDown)
                        {
                            if (Selection.objects.Length != 0)
                            {
                                PeekLogic.AddToIndex(-1);
                            }
                            PeekLogic.ForceSelection(PeekSerializeObject.SelectedObjectsIndex(PeekSerializeObject.CurrentIndex));
                        }
#if UNITY_2018_3_OR_NEWER
                        if (IsRightClickContext())
                        {
                            return(true);
                        }
#endif
                        bool          isScrollingUp = ExtMouse.IsScrollingUp(Event.current, ref delta);
                        StringBuilder nextTip       = new StringBuilder();
                        nextTip.Append("Go to next selection (");
                        nextTip.Append(ExtShortCutEditor.GetModifierKey(UnityEssentialsPreferences.SHORTCUT_MODIFIER_KEY_FOR_PREVIOUS_NEXT_SELECTION, (int)UnityEssentialsPreferences.DEFAULT_MODIFIER_KEY));
                        nextTip.Append("+");
                        nextTip.Append(ExtShortCutEditor.GetKey(UnityEssentialsPreferences.SHORTCUT_KEY_FOR_NEXT_SELECTION, (int)UnityEssentialsPreferences.DEFAULT_NEXT_KEY));
                        nextTip.Append(")");

                        if ((GUILayout.Button(new GUIContent(NEXT_ICON, nextTip.ToString()), ExtGUIStyles.MicroButton, GUILayout.Width(23), GUILayout.Height(EditorGUIUtility.singleLineHeight)) && Event.current.button == 0) || isScrollingUp)
                        {
                            PeekLogic.AddToIndex(1);
                            PeekLogic.ForceSelection(PeekSerializeObject.SelectedObjectsIndex(PeekSerializeObject.CurrentIndex));
                        }
#if UNITY_2018_3_OR_NEWER
                        if (IsRightClickContext())
                        {
                            return(true);
                        }
#endif

                        if (PeekSerializeObject.SelectedObjectsCount == 0)
                        {
                            GUIContent gUIContent = new GUIContent("-/-", "there is no previously selected objects");
                            GUILayout.Label(gUIContent);
                        }
                        else
                        {
                            string     showCount  = (PeekSerializeObject.CurrentIndex + 1).ToString() + "/" + (PeekSerializeObject.SelectedObjectsCount);
                            GUIContent gUIContent = new GUIContent(showCount, "Scroll Up/Down to browse previous/next");
                            GUILayout.Label(gUIContent);
                        }
                    }
                    EditorGUI.EndDisabledGroup();
                }
            }
            GUILayout.FlexibleSpace();
            return(false);
        }
Exemplo n.º 27
0
 private void OnSelectedObjectRemove(int index)
 {
     PeekSerializeObject.RemoveItemInSelection(index);
 }
Exemplo n.º 28
0
 private void OnPinnedObjectClicked(int index)
 {
     SelectItem(PeekSerializeObject.PinnedObjectsIndex(index));
 }
Exemplo n.º 29
0
 private void OnSelectedObjectListClear()
 {
     PeekSerializeObject.ClearSelectedList();
 }
Exemplo n.º 30
0
 public static void AddToIndex(int add)
 {
     PeekSerializeObject.AddToIndex(add);
     PeekSerializeObject.Save(30);
 }