예제 #1
0
        private void ApplyFilter()
        {
            dirty = false;

            if (refs == null)
            {
                return;
            }

            if (list == null)
            {
                list = new List <FR2_Ref>();
            }
            else
            {
                list.Clear();
            }

            int minScore = searchTerm.Length;

            string term1 = searchTerm;

            if (!caseSensitive)
            {
                term1 = term1.ToLower();
            }

            string term2 = term1.Replace(" ", string.Empty);

            excludeCount = 0;

            foreach (KeyValuePair <string, FR2_Ref> item in refs)
            {
                FR2_Ref r = item.Value;

                if (r.depth == 0 && !FR2_Setting.ShowSelection)
                {
                    continue;
                }

                if (FR2_Setting.IsTypeExcluded(r.type))
                {
                    excludeCount++;
                    continue;                     //skip this one
                }

                if (!showSearch || string.IsNullOrEmpty(searchTerm))
                {
                    r.matchingScore = 0;
                    list.Add(r);
                    continue;
                }

                //calculate matching score
                string name1 = r.isSceneRef ? (r as FR2_SceneRef).sceneFullPath : r.asset.assetName;
                if (!caseSensitive)
                {
                    name1 = name1.ToLower();
                }

                string name2 = name1.Replace(" ", string.Empty);

                int score1 = FR2_Unity.StringMatch(term1, name1);
                int score2 = FR2_Unity.StringMatch(term2, name2);

                r.matchingScore = Mathf.Max(score1, score2);
                if (r.matchingScore > minScore)
                {
                    list.Add(r);
                }
            }

            RefreshSort();
        }
예제 #2
0
        // void OnActive
        private void RefreshView(CBParams assetList)
        {
            cacheAssetList = assetList;
            dirty          = false;
            list           = new List <FR2_Ref>();
            refs           = new Dictionary <string, FR2_Ref>();
            dicIndex       = new Dictionary <string, List <FR2_Ref> >();
            if (assetList == null)
            {
                return;
            }

            int    minScore = searchTerm.Length;
            string term1    = searchTerm;

            if (!caseSensitive)
            {
                term1 = term1.ToLower();
            }

            string term2 = term1.Replace(" ", string.Empty);

            excludeCount = 0;

            for (var i = 0; i < assetList.Count; i++)
            {
                var lst = new List <FR2_Ref>();
                for (var j = 0; j < assetList[i].Count; j++)
                {
                    string guid = AssetDatabase.AssetPathToGUID(assetList[i][j]);
                    if (string.IsNullOrEmpty(guid))
                    {
                        continue;
                    }

                    if (refs.ContainsKey(guid))
                    {
                        continue;
                    }

                    FR2_Asset asset = FR2_Cache.Api.Get(guid);
                    if (asset == null)
                    {
                        continue;
                    }

                    var fr2 = new FR2_Ref(i, 0, asset, null);

                    if (FR2_Setting.IsTypeExcluded(fr2.type))
                    {
                        excludeCount++;
                        continue;                         //skip this one
                    }

                    if (string.IsNullOrEmpty(searchTerm))
                    {
                        fr2.matchingScore = 0;
                        list.Add(fr2);
                        lst.Add(fr2);
                        refs.Add(guid, fr2);
                        continue;
                    }

                    //calculate matching score
                    string name1 = fr2.asset.assetName;
                    if (!caseSensitive)
                    {
                        name1 = name1.ToLower();
                    }

                    string name2 = name1.Replace(" ", string.Empty);

                    int score1 = FR2_Unity.StringMatch(term1, name1);
                    int score2 = FR2_Unity.StringMatch(term2, name2);

                    fr2.matchingScore = Mathf.Max(score1, score2);
                    if (fr2.matchingScore > minScore)
                    {
                        list.Add(fr2);
                        lst.Add(fr2);
                        refs.Add(guid, fr2);
                    }
                }

                dicIndex.Add(i.ToString(), lst);
            }

            ResetGroup();
        }