Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
 private void SelectItem(UnityEngine.Object toSelect, bool select = true)
 {
     PeekLogic.ForceSelection(toSelect, select: select, showNameInSceneView: true, canDoubleClic: true);
 }
Ejemplo n.º 3
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);
        }