Beispiel #1
0
        /// <summary>
        /// Useful to search a given scriptableObject
        /// Find the last object of the given type in the project
        /// (if this type has never been selected, search in project)
        /// usage:
        /// UnityEngine.Object found = null;
        /// PeekLogic.GetLastObjectOfThisTypeOrFindItInAsset<YourScriptType>(ref found, "Assets/");
        /// </summary>
        /// <typeparam name="T">type of asset to search</typeparam>
        /// <param name="found"></param>
        /// <param name="pathWhereToSearch"></param>
        /// <returns></returns>
        public static T GetLastObjectOfThisTypeOrFindItInAsset <T>(ref UnityEngine.Object found, string pathWhereToSearch = "Assets/") where T : UnityEngine.Object
        {
            T    element;
            bool hasFound = PeekLogic.GetLastObjectOfThisType <T>(ref found);

            if (hasFound)
            {
                return(found as T);
            }
            else
            {
                element = ExtFindEditor.GetAssetByGenericType <T>(pathWhereToSearch);
                return(element);
            }
        }
Beispiel #2
0
 private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
 {
     try
     {
         foreach (string deletedAsset in deletedAssets)
         {
             string extension = Path.GetExtension(deletedAsset);
             if (string.Equals(extension, ".unity"))
             {
                 PeekLogic.DeleteBookMarkedGameObjectLinkedToScene();
                 return;
             }
         }
     }
     catch { }
 }
Beispiel #3
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);
        }
Beispiel #4
0
 private void OnSelectedObjectBookMarkClicked(int index)
 {
     PeekLogic.SaveToBookMark(PeekSerializeObject.SelectedObjectsWithoutDuplicateIndex(index), index);
 }
Beispiel #5
0
 private void OnPinnedSceneGameObjectInfoOpenScene(int index)
 {
     PeekLogic.SwapSceneAndSelectItem(PeekSerializeObject.PinnedObjectsScenesLinkIndex(index).GetPath(), PeekSerializeObject.PinnedObjectsNameInScenesIndex(index), PeekSerializeObject.PinnedObjectsScenesLinkIndex(index).name);
 }
Beispiel #6
0
 private void SelectItem(UnityEngine.Object toSelect, bool select = true)
 {
     PeekLogic.ForceSelection(toSelect, select: select, showNameInSceneView: true, canDoubleClic: true);
 }
Beispiel #7
0
 private static void SceneOpenedCallback(Scene scene, UnityEditor.SceneManagement.OpenSceneMode mode)
 {
     PeekLogic.UpdateSceneGameObjectFromSceneLoad(scene);
 }
Beispiel #8
0
 private static void SceneOpenedPlayModeCallback(Scene scene, LoadSceneMode mode)
 {
     PeekLogic.UpdateSceneGameObjectFromSceneLoad(scene);
 }
        /// <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);
        }
Beispiel #10
0
 public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
 {
     PeekLogic.UpdateSceneGameObjectOnLoad();
 }