浏览代码

Tag Fitlering System (#15)

/main
GitHub 5 年前
当前提交
74dd8cca
共有 4 个文件被更改,包括 45 次插入0 次删除
  1. 6
      CHANGELOG.md
  2. 11
      Editor/Discover/DiscoverAsset.cs
  3. 27
      Editor/Discover/DiscoverWindow.cs
  4. 1
      Runtime/Discover/Discover.cs

6
CHANGELOG.md


# Changelog
## 2019.3.5
#### Added
- Discover : Tag Filtering System
## 2019.3.4
This version added the following package dependencies:

11
Editor/Discover/DiscoverAsset.cs


[Tooltip("The name of the preference for auto showing at startup, will be ")]
public string PreferenceName = "Discover";
[Header("Filter Content")]
public FilterMode filterMode = FilterMode.ShowAll;
public string Tags = "";
public enum FilterMode
{
ShowAll,
IncludeTags,
ExcludeTags
}
[Header("Content")]
public string Title = "Welcome!";
[Multiline]

27
Editor/Discover/DiscoverWindow.cs


UpdateDiscoverObjects();
}
/// <summary>
/// Filters object based on asset tags, object tags and FilterMode
/// </summary>
/// <param name="asset"></param>
/// <param name="discoverObject"></param>
/// <returns>true to discard, false to keep</returns>
static bool FilterDiscoverObject(DiscoverAsset asset, Discover discoverObject)
{
string[] assetTags = asset.Tags.Split(' ');
string[] objectTags = discoverObject.Tags.Split(' ');
switch(asset.filterMode)
{
case DiscoverAsset.FilterMode.ShowAll: return false;
case DiscoverAsset.FilterMode.IncludeTags:
return !assetTags.Intersect(objectTags).Any();
case DiscoverAsset.FilterMode.ExcludeTags:
return assetTags.Intersect(objectTags).Any();
}
return false;
}
void UpdateDiscoverObjects(bool clear = false)
{
if (discoverObjects == null)

// Add new ones
foreach (var item in newOnes)
{
// Apply Filter
if (FilterDiscoverObject(discoverAsset, item))
continue;
if (!discoverObjects.ContainsKey(item.Category))
{
discoverObjects.Add(item.Category, new List<Discover>());

1
Runtime/Discover/Discover.cs


public GameObjectToggle[] ObjectsToToggle = new GameObjectToggle[0];
[Multiline]
public string Description = "Some Description of the Component\n\nCan be set as multiple lines.";
public string Tags = "";
public int Priority = 0;
public DiscoverSection[] Sections = new DiscoverSection[0];

正在加载...
取消
保存