diff --git a/Source/Editor/Surface/ContextMenu/VisjectCM.cs b/Source/Editor/Surface/ContextMenu/VisjectCM.cs
index bae62556e..24cb29cb9 100644
--- a/Source/Editor/Surface/ContextMenu/VisjectCM.cs
+++ b/Source/Editor/Surface/ContextMenu/VisjectCM.cs
@@ -419,7 +419,7 @@ namespace FlaxEditor.Surface.ContextMenu
Profiler.BeginEvent("VisjectCM.OnSearchFilterChanged");
- if (string.IsNullOrEmpty(_searchBox.Text))
+ if (string.IsNullOrEmpty(_searchBox.Text) && _selectedBox == null)
{
ResetView();
Profiler.EndEvent();
@@ -430,7 +430,7 @@ namespace FlaxEditor.Surface.ContextMenu
LockChildrenRecursive();
for (int i = 0; i < _groups.Count; i++)
{
- _groups[i].UpdateFilter(_searchBox.Text);
+ _groups[i].UpdateFilter(_searchBox.Text, _selectedBox);
_groups[i].UpdateItemSort(_selectedBox);
}
SortGroups();
@@ -503,12 +503,19 @@ namespace FlaxEditor.Surface.ContextMenu
_searchBox.Clear();
SelectedItem = null;
for (int i = 0; i < _groups.Count; i++)
+ {
_groups[i].ResetView();
+ }
UnlockChildrenRecursive();
SortGroups();
PerformLayout();
+ for (int i = 0; i < _groups.Count; i++)
+ {
+ _groups[i].EvaluateVisibilityWithBox(_selectedBox);
+ }
+
Profiler.EndEvent();
}
@@ -626,10 +633,11 @@ namespace FlaxEditor.Surface.ContextMenu
// Prepare
UpdateSurfaceParametersGroup();
ResetView();
+
_panel1.VScrollBar.TargetValue = 0;
Focus();
_waitingForInput = true;
-
+
base.OnShow();
}
diff --git a/Source/Editor/Surface/ContextMenu/VisjectCMGroup.cs b/Source/Editor/Surface/ContextMenu/VisjectCMGroup.cs
index 446840f2c..cd189ab94 100644
--- a/Source/Editor/Surface/ContextMenu/VisjectCMGroup.cs
+++ b/Source/Editor/Surface/ContextMenu/VisjectCMGroup.cs
@@ -66,7 +66,7 @@ namespace FlaxEditor.Surface.ContextMenu
{
if (_children[i] is VisjectCMItem item)
{
- item.UpdateFilter(null);
+ item.UpdateFilter(null, null);
item.UpdateScore(null);
}
}
@@ -84,7 +84,7 @@ namespace FlaxEditor.Surface.ContextMenu
/// Updates the filter.
///
/// The filter text.
- public void UpdateFilter(string filterText)
+ public void UpdateFilter(string filterText, Box selectedBox)
{
Profiler.BeginEvent("VisjectCMGroup.UpdateFilter");
@@ -94,13 +94,13 @@ namespace FlaxEditor.Surface.ContextMenu
{
if (_children[i] is VisjectCMItem item)
{
- item.UpdateFilter(filterText);
+ item.UpdateFilter(filterText, selectedBox);
isAnyVisible |= item.Visible;
}
}
// Update header title
- if (QueryFilterHelper.Match(filterText, HeaderText))
+ /*if (QueryFilterHelper.Match(filterText, HeaderText))
{
for (int i = 0; i < _children.Count; i++)
{
@@ -110,7 +110,7 @@ namespace FlaxEditor.Surface.ContextMenu
}
}
isAnyVisible = true;
- }
+ }*/
// Update itself
if (isAnyVisible)
@@ -128,6 +128,35 @@ namespace FlaxEditor.Surface.ContextMenu
Profiler.EndEvent();
}
+ public void EvaluateVisibilityWithBox(Box selectedBox)
+ {
+ if (selectedBox == null)
+ {
+ Visible = true;
+ return;
+ }
+
+ bool isAnyVisible = false;
+ for (int i = 0; i < _children.Count; i++)
+ {
+ if (_children[i] is VisjectCMItem item)
+ {
+ isAnyVisible |= item.IsCompatibleWithBox(selectedBox);
+ }
+ }
+
+ // Update itself
+ if (isAnyVisible)
+ {
+ Visible = true;
+ }
+ else
+ {
+ // Hide group if none of the items matched the filter
+ Visible = false;
+ }
+ }
+
///
/// Updates the sorting of the s of this
/// Also updates the
diff --git a/Source/Editor/Surface/ContextMenu/VisjectCMItem.cs b/Source/Editor/Surface/ContextMenu/VisjectCMItem.cs
index b68d529a1..b2d5fd7a8 100644
--- a/Source/Editor/Surface/ContextMenu/VisjectCMItem.cs
+++ b/Source/Editor/Surface/ContextMenu/VisjectCMItem.cs
@@ -113,12 +113,51 @@ namespace FlaxEditor.Surface.ContextMenu
return false;
}
+ public bool IsCompatibleWithBox(Box box)
+ {
+ if (box == null)
+ return true;
+
+ if(_archetype?.Elements == null)
+ return false;
+
+ bool isCompatible = false;
+ foreach (NodeElementArchetype element in _archetype.Elements)
+ {
+ if(element.Type != NodeElementType.Output && element.Type != NodeElementType.Input)
+ continue;
+
+ if ((box.IsOutput && element.Type == NodeElementType.Output) || (!box.IsOutput && element.Type == NodeElementType.Input))
+ continue;
+
+ bool checkCompatibility = box.CanUseType(element.ConnectionsType);;
+ if (!checkCompatibility)
+ {
+ if ((element.ConnectionsType == null || element.ConnectionsType == typeof(void)) && box.CurrentType != typeof(FlaxEngine.Object))
+ checkCompatibility = true;
+ }
+ isCompatible |= checkCompatibility;
+
+ /*if(!isCompatible)
+ Debug.Log($"Is {_archetype.Title} cant connect type {element.ConnectionsType}");*/
+ }
+
+ Visible = isCompatible;
+ return isCompatible;
+ }
+
///
/// Updates the filter.
///
/// The filter text.
- public void UpdateFilter(string filterText)
+ public void UpdateFilter(string filterText, Box selectedBox)
{
+ if (selectedBox != null)
+ {
+ if (!IsCompatibleWithBox(selectedBox))
+ return;
+ }
+
_isStartsWithMatch = _isFullMatch = false;
if (filterText == null)
{
@@ -192,7 +231,7 @@ namespace FlaxEditor.Surface.ContextMenu
}
}
}
-
+
///
public override void Draw()
{