コード例 #1
0
        public override void Draw()
        {
#if PSR_FULL
            if (dtd.parent.searchItem is SearchItemProperty)
            {
                SearchItemProperty propSearch = dtd.parent.searchItem as SearchItemProperty;
                if (objID.obj != propSearch.objID.obj)
                {
                    ObjectUtil.ValidateAndAssign(propSearch.objID.obj, objID, searchProperty, ref initializationContext);
                }
            }
            else
            {
                showDragAndDrop();
            }
            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);
                setType(initializationContext.fieldData.fieldType);

                if (subItem != null)
                {
                    subItem.options         = options;
                    subItem.showMoreOptions = showMoreOptions;
                    subItem.Draw();
                }
                else
                {
                    EditorGUILayout.LabelField("Unsupported type:" + type);
                }
            }
#endif
        }
コード例 #2
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);
            }
        }