private List <string> GetFilteredAssets(ImportDefinitionProfile profile)
        {
            List <string> associatedAssets = new List <string>();
            List <string> ignorePaths      = new List <string>();
            string        searchFilter;

            List <string> GUIDs;

            // TODO this is probably inefficient, profile and see if there is a more efficient design needed
            if (m_Profile.m_ImportTasks.Count > 0)
            {
                m_Profile.m_ImportTasks[0].GetSearchFilter(out searchFilter, ignorePaths);
                GUIDs = new List <string>(AssetDatabase.FindAssets(searchFilter));

                for (int i = 1; i < m_Profile.m_ImportTasks.Count; ++i)
                {
                    m_Profile.m_ImportTasks[i].GetSearchFilter(out searchFilter, ignorePaths);
                    string[] moduleGUIDs = AssetDatabase.FindAssets(searchFilter);
                    for (int m = GUIDs.Count - 1; m >= 0; --m)
                    {
                        bool guidInModule = false;
                        foreach (string moduleGuiD in moduleGUIDs)
                        {
                            if (GUIDs[m] == moduleGuiD)
                            {
                                guidInModule = true;
                                break;
                            }
                        }
                        if (guidInModule == false)
                        {
                            GUIDs.RemoveAt(m);
                        }
                    }
                }
            }
            else
            {
                GUIDs = new List <string>(AssetDatabase.FindAssets(""));
            }

            //string[] GUIDs = AssetDatabase.FindAssets( typeFilter );
            foreach (var assetGUID in GUIDs)
            {
                string assetPath = AssetDatabase.GUIDToAssetPath(assetGUID);

                // some items may appear twice, due to sub assets, e.g. Sprite
                if (ignorePaths.Contains(assetPath) || associatedAssets.Contains(assetPath))
                {
                    continue;
                }

                if (Filter.Conforms(assetPath, profile.GetFilters()))
                {
                    associatedAssets.Add(assetPath);
                }
            }

            return(associatedAssets);
        }
        public override void OnInspectorGUI()
        {
            if (m_Profile == null)
            {
                m_Profile = (ImportDefinitionProfile)target;
            }

            Rect        viewRect = GUILayoutUtility.GetRect(EditorGUIUtility.currentViewWidth - 23, 0);
            ControlRect layout   = new ControlRect(viewRect.x, viewRect.y, viewRect.width);

            layout.Space(10);
            EditorGUI.PropertyField(layout.Get(), m_FolderOnly, new GUIContent("Lock to folder", "Include a filter to limit this profile to this profile only"));
            EditorGUI.PropertyField(layout.Get(), m_ProcessOnImport, new GUIContent("Process On Import"));
            EditorGUI.PropertyField(layout.Get(), m_SortIndex, new GUIContent("Sort Index"));
            layout.Space(10);

            EditorGUI.LabelField(layout.Get(), "Search Filter's");

            List <Filter> filters = m_Profile.GetFilters(true);

            if (filters == null)
            {
                filters = new List <Filter>();
            }

            int filterCount = filters.Count;

            if (m_FolderOnly.boolValue)
            {
                filterCount++;
            }

            Rect boxAreaRect = layout.Get((16 * filterCount) + (3 * filterCount) + 6);

            GUI.Box(boxAreaRect, GUIContent.none);

            ControlRect subLayout = new ControlRect(boxAreaRect.x + 3, boxAreaRect.y + 3, boxAreaRect.width - 6, 16);

            subLayout.padding = 3;

            int removeAt = -1;
            int size     = m_FiltersListProperty.arraySize;

            if (m_FolderOnly.boolValue)
            {
                size++;
            }

            for (int i = 0; i < size; ++i)
            {
                Rect segmentRect = subLayout.Get();
                segmentRect.x     += 3;
                segmentRect.width -= 6;

                float segWidth = (segmentRect.width - segmentRect.height) / 3;
                segmentRect.width = segWidth - 3;
                float startX = segmentRect.x;

                if (m_FolderOnly.boolValue && i == size - 1)
                {
                    EditorGUI.BeginDisabledGroup(true);
                    EditorGUI.EnumPopup(segmentRect, Filter.ConditionTarget.Directory);
                    segmentRect.x = startX + segWidth;
                    EditorGUI.EnumPopup(segmentRect, Filter.Condition.StartsWith);
                    segmentRect.x = startX + (segWidth * 2);
                    EditorGUI.TextField(segmentRect, m_Profile.DirectoryPath);
                    EditorGUI.EndDisabledGroup();
                }
                else
                {
                    SerializedProperty filterProperty = m_FiltersListProperty.GetArrayElementAtIndex(i);
                    filterProperty.NextVisible(true);
                    do
                    {
                        if (filterProperty.propertyType == SerializedPropertyType.Enum && filterProperty.name == "m_Target")
                        {
                            segmentRect.x = startX;
                            EditorGUI.PropertyField(segmentRect, filterProperty, GUIContent.none);
                        }
                        else if (filterProperty.propertyType == SerializedPropertyType.Enum && filterProperty.name == "m_Condition")
                        {
                            segmentRect.x = startX + segWidth;
                            EditorGUI.PropertyField(segmentRect, filterProperty, GUIContent.none);
                        }
                        else if (filterProperty.propertyType == SerializedPropertyType.String && filterProperty.name == "m_Wildcard")
                        {
                            segmentRect.x = startX + (segWidth * 2);
                            EditorGUI.PropertyField(segmentRect, filterProperty, GUIContent.none);
                        }
                    } while(filterProperty.NextVisible(false));

                    segmentRect.x     = startX + (segWidth * 3);
                    segmentRect.width = segmentRect.height;
                    if (GUI.Button(segmentRect, "-"))
                    {
                        removeAt = i;
                    }
                }
            }

            if (removeAt >= 0)
            {
                m_FiltersListProperty.DeleteArrayElementAtIndex(removeAt);
            }

            Rect layoutRect = layout.Get();

            layoutRect.x     = layoutRect.x + (layoutRect.width - 40);
            layoutRect.width = 40;
            if (GUI.Button(layoutRect, "Add"))
            {
                m_FiltersListProperty.arraySize += 1;
            }

            layout.Space(20);

            EditorGUI.LabelField(layout.Get(), "", UnityEngine.GUI.skin.horizontalSlider);

            size = m_Tasks.arraySize;
            for (int i = 0; i < size; ++i)
            {
                if (m_ImportTaskFoldoutStates.Count - 1 < i)
                {
                    m_ImportTaskFoldoutStates.Add(true);
                }

                SerializedProperty taskProperty = m_Tasks.GetArrayElementAtIndex(i);
                BaseImportTask     importTask   = taskProperty.objectReferenceValue as BaseImportTask;
                if (importTask == null)
                {
                    continue;
                }

                if (i > 0)
                {
                    layout.Space(10);
                }

                Rect headerRect = layout.Get(20);
                m_ImportTaskFoldoutStates[i] = EditorGUI.Foldout(headerRect, m_ImportTaskFoldoutStates[i], importTask.name, true);

                Event current = Event.current;
                if (headerRect.Contains(current.mousePosition))
                {
                    if ((current.type == EventType.MouseDown && current.button == 1) || current.type == EventType.ContextClick)
                    {
                        GenericMenu menu = new GenericMenu();
                        if (i == 0)
                        {
                            menu.AddDisabledItem(new GUIContent("Move Up"));
                        }
                        else
                        {
                            menu.AddItem(new GUIContent("Move Up"), false, MoveTaskUpCallback, i);
                        }
                        if (i == size - 1)
                        {
                            menu.AddDisabledItem(new GUIContent("Move Down"));
                        }
                        else
                        {
                            menu.AddItem(new GUIContent("Move Down"), false, MoveTaskDownCallback, i);
                        }

                        menu.AddSeparator("");
                        menu.AddItem(new GUIContent("Delete Import Task"), false, RemoveTaskCallback, i);
                        menu.ShowAsContext();
                        current.Use();
                    }
                    else if (current.type == EventType.MouseDown && current.button == 0)
                    {
                        m_ImportTaskFoldoutStates[i] = !m_ImportTaskFoldoutStates[i];
                    }
                }

                if (m_ImportTaskFoldoutStates[i])
                {
                    layout.BeginArea(5, 5);

                    importTask.DrawGUI(layout);

                    GUI.depth = GUI.depth - 1;
                    GUI.Box(layout.EndArea(), "");
                    GUI.depth = GUI.depth + 1;
                }
            }

            if (size > 0)
            {
                EditorGUI.LabelField(layout.Get(), "", UnityEngine.GUI.skin.horizontalSlider);
            }

            layoutRect = layout.Get();
            if (layoutRect.width > 120)
            {
                layoutRect.x     = layoutRect.x + (layoutRect.width - 120);
                layoutRect.width = 120;
            }

            if (EditorGUI.DropdownButton(layoutRect, new GUIContent("Add Import Task", "Add new Task to this Definition."), FocusType.Keyboard))
            {
                var menu = new GenericMenu();
                for (int i = 0; i < m_ImportTaskTypes.Count; i++)
                {
                    var type = m_ImportTaskTypes[i];
                    menu.AddItem(new GUIContent(type.Name, ""), false, OnAddImportTask, type);
                }

                menu.ShowAsContext();
            }

            GUILayoutUtility.GetRect(viewRect.width, layoutRect.y + layoutRect.height);
            serializedObject.ApplyModifiedProperties();
        }