Exemple #1
0
 public override void Draw(SearchOptions options)
 {
     if (isCollection())
     {
         setSubtype();
         // Debug.Log("[DynamicTypeCollection] array of "+subType);
         initTypeField();
         typeField.showMoreOptions = showMoreOptions;
         typeField.SetType(initializationContext);
         typeField.Draw(options);
     }
 }
Exemple #2
0
        public override void Draw(SearchOptions options)
        {
            Type subType = parent.type.GetGenericArguments()[0];

            initializationContext = new InitializationContext(subType);

            // Debug.Log("[DynamicTypeCollection] array of "+subType);
            if (typeField == null)
            {
                typeField = new DynamicTypeField();
                typeField.OnDeserialization();
            }
            typeField.SetType(initializationContext);
            typeField.Draw(options);
        }
Exemple #3
0
        public override void Draw(SearchOptions options)
        {
            Type subType = parent.type.GetGenericArguments()[0];

            initializationContext = new InitializationContext(subType);

//      Debug.Log("[DynamicTypeCollection] array of "+subType);
            if (typeField == null)
            {
                typeField = new DynamicTypeField();
                typeField.OnDeserialization();
            }
            if (isSearchByName)
            {
                EditorGUILayout.BeginHorizontal();
                GUILayout.Label("Field:", GUILayout.Width(SRWindow.compactLabelWidthNP));
                searchByNameValue = EditorGUILayout.TextField(searchByNameValue);
                EditorGUILayout.EndHorizontal();
            }
            typeField.SetType(initializationContext);
            typeField.Draw(options);
        }
Exemple #4
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();
        }
Exemple #5
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);
            }
        }