private void UpdateFilter(int instanceID, SearchFilter filter, float previewSize)
        {
            SavedFilter savedFilter = this.Find(instanceID);

            if (savedFilter != null)
            {
                if (filter != null)
                {
                    SearchFilter filter2 = ObjectCopier.DeepClone <SearchFilter>(filter);
                    savedFilter.m_Filter = filter2;
                }
                savedFilter.m_PreviewSize = previewSize;
                this.Changed();
            }
            else
            {
                Debug.LogError(string.Concat(new object[]
                {
                    "Could not find saved filter ",
                    instanceID,
                    " ",
                    ScriptableSingleton <SavedSearchFilters> .instance.ToString()
                }));
            }
        }
Exemple #2
0
        public static SearchFilter GetFilter(int instanceID)
        {
            SavedFilter sf = instance.Find(instanceID);

            if (sf != null && sf.m_Filter != null)
            {
                return(ObjectCopier.DeepClone(sf.m_Filter));
            }
            return(null);
        }
Exemple #3
0
        public static SearchFilter GetFilter(int instanceID)
        {
            SavedFilter savedFilter = ScriptableSingleton <SavedSearchFilters> .instance.Find(instanceID);

            if (savedFilter != null && savedFilter.m_Filter != null)
            {
                return(ObjectCopier.DeepClone <SearchFilter>(savedFilter.m_Filter));
            }
            return((SearchFilter)null);
        }
        int Add(string displayName, SearchFilter filter, float previewSize, int insertAfterInstanceID, bool addAsChild)
        {
            SearchFilter filterCopy = null;

            if (filter != null)
            {
                filterCopy = ObjectCopier.DeepClone(filter);
            }

            // Clear unused data before saving
            if (filterCopy.GetState() == SearchFilter.State.SearchingInAllAssets ||
                filterCopy.GetState() == SearchFilter.State.SearchingInAssetsOnly ||
                filterCopy.GetState() == SearchFilter.State.SearchingInPackagesOnly ||
                filterCopy.GetState() == SearchFilter.State.SearchingInAssetStore)
            {
                filterCopy.folders = new string[0];
            }

            int afterIndex = 0; // add after root index

            if (insertAfterInstanceID != 0)
            {
                afterIndex = IndexOf(insertAfterInstanceID);
                if (afterIndex == -1)
                {
                    Debug.LogError("Invalid insert position");
                    return(0);
                }
            }

            int depth = m_SavedFilters[afterIndex].m_Depth + (addAsChild ? 1 : 0);

            SavedFilter savedFilter = new SavedFilter(displayName, filterCopy, depth, previewSize);

            savedFilter.m_ID = GetNextAvailableID();

            if (m_SavedFilters.Count == 0)
            {
                m_SavedFilters.Add(savedFilter);
            }
            else
            {
                m_SavedFilters.Insert(afterIndex + 1, savedFilter); // insert after wanted index
            }

            // Select new Saved filter
            //Selection.activeInstanceID = savedFilter.m_ID;

            Changed();
            return(savedFilter.m_ID);
        }
        public static SearchFilter GetFilter(int instanceID)
        {
            SavedFilter savedFilter = ScriptableSingleton <SavedSearchFilters> .instance.Find(instanceID);

            SearchFilter result;

            if (savedFilter != null && savedFilter.m_Filter != null)
            {
                result = ObjectCopier.DeepClone <SearchFilter>(savedFilter.m_Filter);
            }
            else
            {
                result = null;
            }
            return(result);
        }
Exemple #6
0
        private void UpdateFilter(int instanceID, SearchFilter filter, float previewSize)
        {
            SavedFilter savedFilter = this.Find(instanceID);

            if (savedFilter != null)
            {
                if (filter != null)
                {
                    SearchFilter searchFilter = ObjectCopier.DeepClone <SearchFilter>(filter);
                    savedFilter.m_Filter = searchFilter;
                }
                savedFilter.m_PreviewSize = previewSize;
                this.Changed();
            }
            else
            {
                Debug.LogError((object)("Could not find saved filter " + (object)instanceID + " " + ScriptableSingleton <SavedSearchFilters> .instance.ToString()));
            }
        }
        private int Add(string displayName, SearchFilter filter, float previewSize, int insertAfterInstanceID, bool addAsChild)
        {
            SearchFilter searchFilter = null;

            if (filter != null)
            {
                searchFilter = ObjectCopier.DeepClone <SearchFilter>(filter);
            }
            if (searchFilter.GetState() == SearchFilter.State.SearchingInAllAssets || searchFilter.GetState() == SearchFilter.State.SearchingInAssetStore)
            {
                searchFilter.folders = new string[0];
            }
            int num = 0;
            int result;

            if (insertAfterInstanceID != 0)
            {
                num = this.IndexOf(insertAfterInstanceID);
                if (num == -1)
                {
                    Debug.LogError("Invalid insert position");
                    result = 0;
                    return(result);
                }
            }
            int         depth       = this.m_SavedFilters[num].m_Depth + ((!addAsChild) ? 0 : 1);
            SavedFilter savedFilter = new SavedFilter(displayName, searchFilter, depth, previewSize);

            savedFilter.m_ID = this.GetNextAvailableID();
            if (this.m_SavedFilters.Count == 0)
            {
                this.m_SavedFilters.Add(savedFilter);
            }
            else
            {
                this.m_SavedFilters.Insert(num + 1, savedFilter);
            }
            this.Changed();
            result = savedFilter.m_ID;
            return(result);
        }
Exemple #8
0
        void UpdateFilter(int instanceID, SearchFilter filter, float previewSize)
        {
            SavedFilter savedFilter = Find(instanceID);

            if (savedFilter != null)
            {
                SearchFilter copiedFilter = null;
                if (filter != null)
                {
                    copiedFilter         = ObjectCopier.DeepClone(filter);
                    savedFilter.m_Filter = copiedFilter;
                }

                savedFilter.m_PreviewSize = previewSize;
                Changed();
            }
            else
            {
                Debug.LogError("Could not find saved filter " + instanceID + " " + instance);
            }
        }
Exemple #9
0
        private int Add(string displayName, SearchFilter filter, float previewSize, int insertAfterInstanceID, bool addAsChild)
        {
            SearchFilter filter2 = null;

            if (filter != null)
            {
                filter2 = ObjectCopier.DeepClone <SearchFilter>(filter);
            }
            if ((filter2.GetState() == SearchFilter.State.SearchingInAllAssets) || (filter2.GetState() == SearchFilter.State.SearchingInAssetStore))
            {
                filter2.folders = new string[0];
            }
            int index = 0;

            if (insertAfterInstanceID != 0)
            {
                index = this.IndexOf(insertAfterInstanceID);
                if (index == -1)
                {
                    Debug.LogError("Invalid insert position");
                    return(0);
                }
            }
            int         depth = this.m_SavedFilters[index].m_Depth + (!addAsChild ? 0 : 1);
            SavedFilter item  = new SavedFilter(displayName, filter2, depth, previewSize)
            {
                m_ID = this.GetNextAvailableID()
            };

            if (this.m_SavedFilters.Count == 0)
            {
                this.m_SavedFilters.Add(item);
            }
            else
            {
                this.m_SavedFilters.Insert(index + 1, item);
            }
            this.Changed();
            return(item.m_ID);
        }