Skip to content

Commit 4a4eabf

Browse files
committed
assets: Search in tags and attributes as well.
1 parent 012c771 commit 4a4eabf

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

VisualPinball.Unity/VisualPinball.Unity.Editor/AssetBrowser/AssetQuery.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
using System.Collections.Generic;
1919
using System.Linq;
2020
using System.Text.RegularExpressions;
21+
using Unity.Mathematics;
2122
using UnityEditor;
2223
using UnityEngine;
2324
using UnityEngine.UIElements;
@@ -159,6 +160,13 @@ public AssetResult(AssetLibrary library, LibraryAsset asset, long score)
159160
Score = score;
160161
}
161162

163+
public void AddScore(long score)
164+
{
165+
Score = Score < 0
166+
? math.max(Score, score)
167+
: math.max(Score, Score + score);
168+
}
169+
162170
public void Save()
163171
{
164172
Library.SaveAsset(Asset);

VisualPinball.Unity/VisualPinball.Unity.Editor/AssetBrowser/LibraryDatabase.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
using System;
2020
using System.Collections.Generic;
2121
using System.Linq;
22+
using Unity.Mathematics;
2223
using UnityEditor;
2324
using UnityEditor.Search;
2425
using UnityEngine;
@@ -41,13 +42,16 @@ public IEnumerable<AssetResult> GetAssets(AssetLibrary lib, LibraryQuery query)
4142
results = results
4243
.Select(result => {
4344
FuzzySearch.FuzzyMatch(query.Keywords, result.Asset.Object.name, ref result.Score);
44-
/* todo fix search in tags and attributes.
4545
foreach (var tag in result.Asset.Tags) {
46-
FuzzySearch.FuzzyMatch(query.Keywords, tag, ref result.Score);
46+
var score = 0L;
47+
FuzzySearch.FuzzyMatch(query.Keywords, tag, ref score);
48+
result.AddScore(score);
4749
}
4850
foreach (var value in result.Asset.Attributes.SelectMany(values => values.Value.Split(","))) {
49-
FuzzySearch.FuzzyMatch(query.Keywords, value, ref result.Score);
50-
}*/
51+
var score = 0L;
52+
FuzzySearch.FuzzyMatch(query.Keywords, value, ref score);
53+
result.AddScore(score);
54+
}
5155
return result;
5256
})
5357
.Where(result => result.Score > 0);

0 commit comments

Comments
 (0)