コード例 #1
0
 private void doSearch()
 {
     // Just in case I'm wrapping this!
     if (currentSearch.CanSearch(searchOptions))
     {
         SearchOptions options = searchOptions.Copy();
         options.searchType = SearchType.Search;
         searchJob          = new SearchJob(currentSearch, options, currentSearch.searchScope.ToData(options));
     }
 }
コード例 #2
0
 private void doSearch()
 {
     // Just in case I'm wrapping this!
     if (currentSearch.CanSearch(searchOptions))
     {
         SearchOptions options = searchOptions.Copy();
         options.searchType = SearchType.Search;
         searchJob          = new SearchJob(currentSearch, options, currentSearch.searchScope.ToData(options));
         searchJob.AddAssets(SearchAssetFactory.GetAssets(currentSearch.searchScope.ToData(options)));
         EditorCoroutineUtility.StartCoroutine(searchJob.ExecuteAsync(), this);
     }
 }
コード例 #3
0
        public override void Draw(SearchOptions options)
        {
            GUIStyle boxStyle = depth == 0 ? SRWindow.searchBox : SRWindow.searchInnerDepthBox;

            GUILayout.BeginHorizontal(boxStyle);
            GUILayout.BeginVertical();
            SRWindow.Instance.CVS();
            drawSubsearch();

            GUILayout.BeginHorizontal();


            float lw = EditorGUIUtility.labelWidth;

            EditorGUIUtility.labelWidth = SRWindow.compactLabelWidth;

            string typeLabel = depth == 0 ? "Type:" : "Subtype:";

            string[] tOptions = depth == 0 ? typeOptions : subTypeOptions;
            int      newIndex = EditorGUILayout.Popup(typeLabel, typeIndex, tOptions, GUILayout.MaxWidth(SRWindow.Instance.position.width - 40));

            EditorGUIUtility.labelWidth = lw; // i love stateful gui! :(

            if (newIndex != typeIndex)
            {
                typeIndex             = newIndex;
                initializationContext = new InitializationContext(typeHash[tOptions[typeIndex]]);
                typeField.SetType(initializationContext);
                SRWindow.Instance.PersistCurrentSearch();
            }

            if (depth == 0)
            {
                if (typeField.hasAdvancedOptions())
                {
                    bool newShowMoreOptions = EditorGUILayout.Toggle(showMoreOptions, SRWindow.optionsToggle, GUILayout.Width(15));
                    if (newShowMoreOptions != showMoreOptions)
                    {
                        showMoreOptions           = newShowMoreOptions;
                        typeField.showMoreOptions = showMoreOptions;
                        SRWindow.Instance.PersistCurrentSearch();
                    }
                }
            }
            else
            {
                // Debug.Log("[SearchItemGlobal] depth:"+depth);
                //show more options is controlled by this search item's parent.
            }
            GUILayout.EndHorizontal();

            typeField.showMoreOptions = showMoreOptions;
            SearchOptions typeFieldOptions = options.Copy();

            if (subsearch != null)
            {
                typeFieldOptions.searchType = SearchType.Search;
            }
            typeField.Draw(typeFieldOptions);

            if (depth == 0)
            {
                if (subsearch != null)
                {
                    SearchItem item = (SearchItem)subsearch;
                    item.Draw(options);
                }

                drawAddRemoveButtons();
            }

            GUILayout.EndVertical();

            SRWindow.Instance.CVE();

            GUILayout.EndHorizontal();
        }
コード例 #4
0
        public override void Draw(SearchOptions options)
        {
            GUILayout.BeginHorizontal(SRWindow.searchBox); // 1
            GUILayout.BeginVertical();

            drawSubsearch();

            GUILayout.BeginHorizontal();
            Rect  r             = EditorGUILayout.BeginHorizontal();
            Event e             = Event.current;
            bool  acceptingDrag = (e.type == EventType.DragUpdated || e.type == EventType.DragPerform) && r.Contains(e.mousePosition);

            if (acceptingDrag)
            {
                if (DragAndDrop.objectReferences.Length == 1)
                {
                    UnityEngine.Object firstObj = DragAndDrop.objectReferences[0];
                    SRWindow.Instance.Repaint();
                    DragAndDrop.AcceptDrag();
                    DragAndDrop.visualMode = DragAndDropVisualMode.Link;
                    if (e.type == EventType.DragPerform)
                    {
                        draggedObj = firstObj;
                    }
                }
                else
                {
                    DragAndDrop.visualMode = DragAndDropVisualMode.Rejected;
                }
            }
            string dragText = null;

            if (objID.obj != null)
            {
                if (objID.obj is MonoScript)
                {
                    MonoScript m = (MonoScript)objID.obj;
                    dragText = "Currently searching " + m.GetClass().Name + "s.";
                }
                else
                {
                    dragText = "Currently searching " + objID.obj.GetType().Name + "s.";
                }
                dragText += "\n(Drag an object here to change search)";
            }
            else
            {
                dragText = "Drag an object here.";
            }

            if (r.Contains(e.mousePosition) && DragAndDrop.visualMode == DragAndDropVisualMode.Link)
            {
                GUILayout.BeginVertical(SRWindow.searchBoxDragHighlight);
                GUILayout.Label(new GUIContent(dragText), SRWindow.richTextStyle);
                GUILayout.EndVertical();
            }
            else
            {
                GUILayout.BeginVertical(SRWindow.searchBox);
                GUILayout.Label(new GUIContent(dragText), SRWindow.richTextStyle);
                GUILayout.EndVertical();
            }
            EditorGUILayout.EndHorizontal();


            if (propertyCriteria.hasAdvancedOptions())
            {
                bool newShowMoreOptions = EditorGUILayout.Toggle(showMoreOptions, SRWindow.optionsToggle, GUILayout.Width(15));
                if (newShowMoreOptions != showMoreOptions)
                {
                    showMoreOptions = newShowMoreOptions;
                    propertyCriteria.showMoreOptions = showMoreOptions;
                    SRWindow.Instance.PersistCurrentSearch();
                }
            }
            GUILayout.EndHorizontal();

            if (objID.obj != null)
            {
                string typeInfo = "";
                if (searchProperty.HasOptions())
                {
                    typeInfo = "Searching the " + searchProperty.fieldData.objectType.Name + " property <b>" + searchProperty.fieldData.fieldName + propertyCriteria.StringValueWithConditional() + "</b>";
                }

                string     warningInfo = "";
                PrefabType pType       = PrefabUtility.GetPrefabType(objID.obj);
                if (pType == PrefabType.None)
                {
                    if (objID.obj is GameObject || objID.obj is Component)
                    {
                        warningInfo = "Referencing a scene component, your search will not be saved on scene change.";
                    }
                    else if (SRWindow.Instance.isSearchingInScene() && !SRWindow.Instance.isSearchingDependencies())
                    {
                        warningInfo = "Searching in a scene but this is not a scene object. No results will be found.";
                    }
                }

                string ssw = subsearchWarning();
                if (ssw != string.Empty)
                {
                    warningInfo += " " + ssw;
                }

                if (warningInfo.Length > 0)
                {
                    EditorGUILayout.HelpBox(warningInfo, MessageType.Warning);
                }
                if (typeInfo.Length > 0)
                {
                    EditorGUILayout.LabelField(typeInfo, SRWindow.richTextStyle);
                }
                searchProperty.Draw();
                if (searchProperty.HasOptions())
                {
                    initializationContext.updateFieldData(searchProperty.fieldData);
                    propertyCriteria.SetType(initializationContext);
                    initializationContext.forceUpdate = false;

                    SearchOptions typeFieldOptions = options.Copy();
                    if (subsearch != null)
                    {
                        typeFieldOptions.searchType = SearchType.Search;
                    }

                    propertyCriteria.Draw(typeFieldOptions);
                }
            }

            if (subsearch != null)
            {
                SearchItem child = (SearchItem)subsearch;
                child.Draw(options);
            }


            drawAddRemoveButtons();
            GUILayout.EndVertical();

            GUILayout.EndHorizontal(); // 1

            if (e.type == EventType.DragExited && draggedObj != null && objID.obj != draggedObj)
            {
                ObjectUtil.ValidateAndAssign(draggedObj, objID, searchProperty, ref initializationContext);
                draggedObj = null;
                propertyCriteria.SetType(initializationContext);
            }
        }