diff --git a/Source/Editor/Modules/ContentFindingModule.cs b/Source/Editor/Modules/ContentFindingModule.cs
index 4fb0ef75f..96d1090a1 100644
--- a/Source/Editor/Modules/ContentFindingModule.cs
+++ b/Source/Editor/Modules/ContentFindingModule.cs
@@ -149,6 +149,10 @@ namespace FlaxEditor.Modules
_searchWin.ShowFloating();
_searchWin.SearchLocation = ContentSearchWindow.SearchLocations.AllAssets;
}
+ if (window is ISearchWindow searchWindow)
+ {
+ _searchWin.SearchAssets = searchWindow.AssetType;
+ }
if (query != null)
{
_searchWin.Query = query;
diff --git a/Source/Editor/Scripting/ScriptType.cs b/Source/Editor/Scripting/ScriptType.cs
index c56d2b8d3..8f93fb1d9 100644
--- a/Source/Editor/Scripting/ScriptType.cs
+++ b/Source/Editor/Scripting/ScriptType.cs
@@ -38,7 +38,7 @@ namespace FlaxEditor.Scripting
///
/// Gets a member name (eg. name of the field or method without leading class name nor namespace prefixes).
///
- public string Name => _managed?.Name ?? _custom?.Name;
+ public string Name => _managed?.Name ?? _custom?.Name ?? string.Empty;
///
/// Gets a metadata token for sorting so it may not be the actual token.
diff --git a/Source/Editor/Surface/Archetypes/Animation.StateMachine.cs b/Source/Editor/Surface/Archetypes/Animation.StateMachine.cs
index 6b0926aba..b3e428b03 100644
--- a/Source/Editor/Surface/Archetypes/Animation.StateMachine.cs
+++ b/Source/Editor/Surface/Archetypes/Animation.StateMachine.cs
@@ -237,6 +237,9 @@ namespace FlaxEditor.Surface.Archetypes
base.OnDestroy();
}
+ ///
+ public Asset SurfaceAsset => null;
+
///
public string SurfaceName => StateMachineTitle;
@@ -1295,6 +1298,9 @@ namespace FlaxEditor.Surface.Archetypes
base.OnDestroy();
}
+ ///
+ public Asset SurfaceAsset => null;
+
///
public string SurfaceName => StateTitle;
@@ -1662,6 +1668,9 @@ namespace FlaxEditor.Surface.Archetypes
data = _data;
}
+ ///
+ public Asset SurfaceAsset => null;
+
///
public string SurfaceName => string.Format("{0} to {1}", SourceState.StateTitle, DestinationState.StateTitle);
diff --git a/Source/Editor/Surface/Archetypes/Function.cs b/Source/Editor/Surface/Archetypes/Function.cs
index b72737f6e..c85386bfd 100644
--- a/Source/Editor/Surface/Archetypes/Function.cs
+++ b/Source/Editor/Surface/Archetypes/Function.cs
@@ -1079,12 +1079,28 @@ namespace FlaxEditor.Surface.Archetypes
base.OnShowSecondaryContextMenu(menu, location);
var method = GetMethod(out _, out _, out _);
- if (method && !method.ValueType.IsVoid)
+ if (method)
{
menu.AddSeparator();
- menu.AddButton((bool)Values[3] ? "Convert to method call" : "Convert to pure node", () => SetValue(3, !(bool)Values[3])).Enabled = Surface.CanEdit;
+ if (!method.ValueType.IsVoid)
+ menu.AddButton((bool)Values[3] ? "Convert to method call" : "Convert to pure node", () => SetValue(3, !(bool)Values[3])).Enabled = Surface.CanEdit;
+ menu.AddButton("Find references...", OnFindReferences);
+ }
+ }
+
+ private void OnFindReferences()
+ {
+ Editor.Instance.ContentFinding.ShowSearch(Surface, '\"' + ContentSearchText + '\"');
+ }
+
+ ///
+ public override string ContentSearchText
+ {
+ get
+ {
+ var method = GetMethod(out var scriptType, out _, out _);
+ return scriptType.TypeName + '.' + method.Name;
}
- // TODO: add Find References option to search Visual Script function usages in the whole project
}
///
@@ -1547,7 +1563,7 @@ namespace FlaxEditor.Surface.Archetypes
menu.AddButton("Add return node", OnAddReturnNode).Enabled = _signature.ReturnType != ScriptType.Null && Surface.CanEdit;
menu.AddButton("Edit signature...", OnEditSignature).Enabled = Surface.CanEdit;
menu.AddButton("Edit attributes...", OnEditAttributes).Enabled = Surface.CanEdit;
- // TODO: add Find References option to search Visual Script function usages in the whole project
+ menu.AddButton("Find references...", OnFindReferences);
}
private void OnAddReturnNode()
@@ -1638,6 +1654,11 @@ namespace FlaxEditor.Surface.Archetypes
editor.Show(this, Vector2.Zero);
}
+ private void OnFindReferences()
+ {
+ Editor.Instance.ContentFinding.ShowSearch(Surface, '\"' + ContentSearchText + '\"');
+ }
+
private void CheckFunctionName(ref string name)
{
if (string.IsNullOrEmpty(name))
@@ -1651,6 +1672,20 @@ namespace FlaxEditor.Surface.Archetypes
name = value;
}
+ ///
+ public override string ContentSearchText
+ {
+ get
+ {
+ var visualScript = Context.Context.SurfaceAsset as VisualScript;
+ if (visualScript == null && Surface is VisualScriptSurface visualScriptSurface)
+ visualScript = visualScriptSurface.Script;
+ if (visualScript != null)
+ return visualScript.ScriptTypeName + '.' + _signature.Name;
+ return _signature.Name;
+ }
+ }
+
///
public override bool OnMouseDoubleClick(Vector2 location, MouseButton button)
{
@@ -1743,20 +1778,19 @@ namespace FlaxEditor.Surface.Archetypes
}
}
- private sealed class GetFieldNode : SurfaceNode
+ private abstract class FieldNodeBase : SurfaceNode
{
private bool _isTypesChangedEventRegistered;
- ///
- public GetFieldNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch)
+ protected FieldNodeBase(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch)
: base(id, context, nodeArch, groupArch)
{
}
- private void UpdateSignature()
+ protected ScriptMemberInfo GetField(out ScriptType scriptType)
{
var fieldInfo = ScriptMemberInfo.Null;
- var scriptType = TypeUtils.GetType((string)Values[0]);
+ scriptType = TypeUtils.GetType((string)Values[0]);
if (scriptType != ScriptType.Null)
{
var members = scriptType.GetMembers((string)Values[1], MemberTypes.Field, BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly);
@@ -1774,6 +1808,68 @@ namespace FlaxEditor.Surface.Archetypes
_isTypesChangedEventRegistered = true;
Editor.Instance.CodeEditing.TypesChanged += UpdateSignature;
}
+ return fieldInfo;
+ }
+
+ protected abstract void UpdateSignature();
+
+ ///
+ public override void OnShowSecondaryContextMenu(FlaxEditor.GUI.ContextMenu.ContextMenu menu, Vector2 location)
+ {
+ base.OnShowSecondaryContextMenu(menu, location);
+
+ if (GetField(out _) == ScriptMemberInfo.Null)
+ return;
+ menu.AddSeparator();
+ menu.AddButton("Find references...", OnFindReferences);
+ }
+
+ private void OnFindReferences()
+ {
+ Editor.Instance.ContentFinding.ShowSearch(Surface, '\"' + ContentSearchText + '\"');
+ }
+
+ ///
+ public override string ContentSearchText
+ {
+ get
+ {
+ var fieldInfo = GetField(out var scriptType);
+ return scriptType.TypeName + '.' + fieldInfo.Name;
+ }
+ }
+
+ ///
+ public override void OnValuesChanged()
+ {
+ base.OnValuesChanged();
+
+ UpdateSignature();
+ }
+
+ ///
+ public override void OnDestroy()
+ {
+ if (_isTypesChangedEventRegistered)
+ {
+ _isTypesChangedEventRegistered = false;
+ Editor.Instance.CodeEditing.TypesChanged -= UpdateSignature;
+ }
+
+ base.OnDestroy();
+ }
+ }
+
+ private sealed class GetFieldNode : FieldNodeBase
+ {
+ public GetFieldNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch)
+ : base(id, context, nodeArch, groupArch)
+ {
+ }
+
+ protected override void UpdateSignature()
+ {
+ var fieldInfo = GetField(out var scriptType);
ScriptType type;
bool isStatic;
if (fieldInfo)
@@ -1816,58 +1912,18 @@ namespace FlaxEditor.Surface.Archetypes
Title = "Get " + SurfaceUtils.GetMethodDisplayName((string)Values[1]);
UpdateSignature();
}
-
- ///
- public override void OnValuesChanged()
- {
- base.OnValuesChanged();
-
- UpdateSignature();
- }
-
- ///
- public override void OnDestroy()
- {
- if (_isTypesChangedEventRegistered)
- {
- _isTypesChangedEventRegistered = false;
- Editor.Instance.CodeEditing.TypesChanged -= UpdateSignature;
- }
-
- base.OnDestroy();
- }
}
- private sealed class SetFieldNode : SurfaceNode
+ private sealed class SetFieldNode : FieldNodeBase
{
- private bool _isTypesChangedEventRegistered;
-
public SetFieldNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch)
: base(id, context, nodeArch, groupArch)
{
}
- private void UpdateSignature()
+ protected override void UpdateSignature()
{
- var fieldInfo = ScriptMemberInfo.Null;
- var scriptType = TypeUtils.GetType((string)Values[0]);
- if (scriptType != ScriptType.Null)
- {
- var members = scriptType.GetMembers((string)Values[1], MemberTypes.Field, BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly);
- foreach (var member in members)
- {
- if (SurfaceUtils.IsValidVisualScriptField(member))
- {
- fieldInfo = member;
- break;
- }
- }
- }
- if (!_isTypesChangedEventRegistered)
- {
- _isTypesChangedEventRegistered = true;
- Editor.Instance.CodeEditing.TypesChanged += UpdateSignature;
- }
+ var fieldInfo = GetField(out var scriptType);
ScriptType type;
bool isStatic;
if (fieldInfo)
@@ -1909,26 +1965,6 @@ namespace FlaxEditor.Surface.Archetypes
Title = "Set " + SurfaceUtils.GetMethodDisplayName((string)Values[1]);
UpdateSignature();
}
-
- ///
- public override void OnValuesChanged()
- {
- base.OnValuesChanged();
-
- UpdateSignature();
- }
-
- ///
- public override void OnDestroy()
- {
- if (_isTypesChangedEventRegistered)
- {
- _isTypesChangedEventRegistered = false;
- Editor.Instance.CodeEditing.TypesChanged -= UpdateSignature;
- }
-
- base.OnDestroy();
- }
}
private abstract class EventBaseNode : SurfaceNode, IFunctionsDependantNode
diff --git a/Source/Editor/Surface/Archetypes/Parameters.cs b/Source/Editor/Surface/Archetypes/Parameters.cs
index 89118c026..bdce86771 100644
--- a/Source/Editor/Surface/Archetypes/Parameters.cs
+++ b/Source/Editor/Surface/Archetypes/Parameters.cs
@@ -267,8 +267,12 @@ namespace FlaxEditor.Surface.Archetypes
private SurfaceParameter GetSelected()
{
- var selectedIndex = _combobox.SelectedIndex;
- return selectedIndex >= 0 && selectedIndex < Surface.Parameters.Count ? Surface.Parameters[selectedIndex] : null;
+ if (Surface != null)
+ {
+ var selectedIndex = _combobox.SelectedIndex;
+ return selectedIndex >= 0 && selectedIndex < Surface.Parameters.Count ? Surface.Parameters[selectedIndex] : null;
+ }
+ return Context.GetParameter((Guid)Values[0]);
}
private void ClearDynamicElements()
@@ -278,6 +282,46 @@ namespace FlaxEditor.Surface.Archetypes
_dynamicChildren.Clear();
}
+ ///
+ public override void OnShowSecondaryContextMenu(FlaxEditor.GUI.ContextMenu.ContextMenu menu, Vector2 location)
+ {
+ base.OnShowSecondaryContextMenu(menu, location);
+
+ if (GetSelected() == null)
+ return;
+ menu.AddSeparator();
+ menu.AddButton("Find references...", OnFindReferences);
+ }
+
+ private void OnFindReferences()
+ {
+ var selected = GetSelected();
+ var query = ContentSearchText ?? FlaxEngine.Json.JsonSerializer.GetStringID(selected.ID);
+ Editor.Instance.ContentFinding.ShowSearch(Surface, '\"' + query + '\"');
+ }
+
+ ///
+ public override string ContentSearchText
+ {
+ get
+ {
+ if (Surface is VisualScriptSurface visualScriptSurface)
+ {
+ // Override with parameter typename
+ var selected = GetSelected();
+ return visualScriptSurface.Script.ScriptTypeName + '.' + selected.Name;
+ }
+ if (Context.Context.SurfaceAsset is VisualScript visualScript)
+ {
+ // Override with parameter typename
+ var selected = Context.GetParameter((Guid)Values[0]);
+ if (selected != null)
+ return visualScript.ScriptTypeName + '.' + selected.Name;
+ }
+ return null;
+ }
+ }
+
///
public void OnParamCreated(SurfaceParameter param)
{
@@ -324,10 +368,7 @@ namespace FlaxEditor.Surface.Archetypes
{
base.OnSurfaceLoaded();
- if (Surface != null)
- {
- UpdateTitle();
- }
+ UpdateTitle();
}
///
@@ -369,8 +410,11 @@ namespace FlaxEditor.Surface.Archetypes
{
var selected = GetSelected();
Title = selected != null ? "Get " + selected.Name : "Get Parameter";
- ResizeAuto();
- _combobox.Width = Width - 30;
+ if (_combobox != null)
+ {
+ ResizeAuto();
+ _combobox.Width = Width - 30;
+ }
}
}
@@ -567,8 +611,52 @@ namespace FlaxEditor.Surface.Archetypes
private SurfaceParameter GetSelected()
{
- var selectedIndex = _combobox.SelectedIndex;
- return selectedIndex >= 0 && selectedIndex < Surface.Parameters.Count ? Surface.Parameters[selectedIndex] : null;
+ if (Surface != null)
+ {
+ var selectedIndex = _combobox.SelectedIndex;
+ return selectedIndex >= 0 && selectedIndex < Surface.Parameters.Count ? Surface.Parameters[selectedIndex] : null;
+ }
+ return Context.GetParameter((Guid)Values[0]);
+ }
+
+ ///
+ public override void OnShowSecondaryContextMenu(FlaxEditor.GUI.ContextMenu.ContextMenu menu, Vector2 location)
+ {
+ base.OnShowSecondaryContextMenu(menu, location);
+
+ if (GetSelected() == null)
+ return;
+ menu.AddSeparator();
+ menu.AddButton("Find references...", OnFindReferences);
+ }
+
+ private void OnFindReferences()
+ {
+ var selected = GetSelected();
+ var query = ContentSearchText ?? FlaxEngine.Json.JsonSerializer.GetStringID(selected.ID);
+ Editor.Instance.ContentFinding.ShowSearch(Surface, '\"' + query + '\"');
+ }
+
+ ///
+ public override string ContentSearchText
+ {
+ get
+ {
+ if (Surface is VisualScriptSurface visualScriptSurface)
+ {
+ // Override with parameter typename
+ var selected = GetSelected();
+ return visualScriptSurface.Script.ScriptTypeName + '.' + selected.Name;
+ }
+ if (Context.Context.SurfaceAsset is VisualScript visualScript)
+ {
+ // Override with parameter typename
+ var selected = Context.GetParameter((Guid)Values[0]);
+ if (selected != null)
+ return visualScript.ScriptTypeName + '.' + selected.Name;
+ }
+ return null;
+ }
}
///
@@ -608,10 +696,8 @@ namespace FlaxEditor.Surface.Archetypes
base.OnLoaded();
if (Surface != null)
- {
UpdateCombo();
- UpdateUI();
- }
+ UpdateUI();
}
///
@@ -641,8 +727,11 @@ namespace FlaxEditor.Surface.Archetypes
box.Enabled = selected != null;
box.CurrentType = selected?.Type ?? ScriptType.Null;
Title = selected != null ? "Set " + selected.Name : "Set Parameter";
- ResizeAuto();
- _combobox.Width = Width - 50;
+ if (_combobox != null)
+ {
+ ResizeAuto();
+ _combobox.Width = Width - 50;
+ }
}
}
diff --git a/Source/Editor/Surface/ISurfaceContext.cs b/Source/Editor/Surface/ISurfaceContext.cs
index d80ca7c77..04bb8f2d3 100644
--- a/Source/Editor/Surface/ISurfaceContext.cs
+++ b/Source/Editor/Surface/ISurfaceContext.cs
@@ -10,6 +10,11 @@ namespace FlaxEditor.Surface
[HideInEditor]
public interface ISurfaceContext
{
+ ///
+ /// Gets the asset containing the surface (optional, null by default).
+ ///
+ Asset SurfaceAsset { get; }
+
///
/// Gets the name of the surface (for UI).
///
diff --git a/Source/Editor/Surface/SurfaceNode.cs b/Source/Editor/Surface/SurfaceNode.cs
index 62e3e35e8..59dfba685 100644
--- a/Source/Editor/Surface/SurfaceNode.cs
+++ b/Source/Editor/Surface/SurfaceNode.cs
@@ -135,6 +135,11 @@ namespace FlaxEditor.Surface
}
}
+ ///
+ /// Gets the custom text for Content Search. Can be used to include node in search results for a specific text query.
+ ///
+ public virtual string ContentSearchText => null;
+
///
/// Gets the color of the footer of the node.
///
diff --git a/Source/Editor/Surface/VisjectSurfaceWindow.cs b/Source/Editor/Surface/VisjectSurfaceWindow.cs
index 0d68f6d2b..583a12833 100644
--- a/Source/Editor/Surface/VisjectSurfaceWindow.cs
+++ b/Source/Editor/Surface/VisjectSurfaceWindow.cs
@@ -577,6 +577,15 @@ namespace FlaxEditor.Surface
/// The context menu.
protected virtual void OnParamContextMenu(int index, FlaxEditor.GUI.ContextMenu.ContextMenu menu)
{
+ menu.AddSeparator();
+ menu.AddButton("Find references...", () => OnFindReferences(index));
+ }
+
+ private void OnFindReferences(int index)
+ {
+ var window = (IVisjectSurfaceWindow)Values[0];
+ var param = window.VisjectSurface.Parameters[index];
+ Editor.Instance.ContentFinding.ShowSearch(window.VisjectSurface, '\"' + FlaxEngine.Json.JsonSerializer.GetStringID(param.ID) + '\"');
}
}
@@ -890,6 +899,9 @@ namespace FlaxEditor.Surface
base.OnAssetLinked();
}
+ ///
+ public Asset SurfaceAsset => Asset;
+
///
public abstract string SurfaceName { get; }
diff --git a/Source/Editor/Viewport/Previews/MaterialPreview.cs b/Source/Editor/Viewport/Previews/MaterialPreview.cs
index 42ad4d273..43d4cf3e2 100644
--- a/Source/Editor/Viewport/Previews/MaterialPreview.cs
+++ b/Source/Editor/Viewport/Previews/MaterialPreview.cs
@@ -341,6 +341,9 @@ namespace FlaxEditor.Viewport.Previews
base.OnDestroy();
}
+ ///
+ public Asset SurfaceAsset => null;
+
///
string ISurfaceContext.SurfaceName => string.Empty;
diff --git a/Source/Editor/Windows/AssetReferencesGraphWindow.cs b/Source/Editor/Windows/AssetReferencesGraphWindow.cs
index 67b2995d3..d430c8282 100644
--- a/Source/Editor/Windows/AssetReferencesGraphWindow.cs
+++ b/Source/Editor/Windows/AssetReferencesGraphWindow.cs
@@ -399,6 +399,9 @@ namespace FlaxEditor.Windows
base.OnDestroy();
}
+ ///
+ public Asset SurfaceAsset => null;
+
///
public string SurfaceName => "References";
diff --git a/Source/Editor/Windows/Assets/AnimationGraphWindow.cs b/Source/Editor/Windows/Assets/AnimationGraphWindow.cs
index 5562e9e0f..9bf9bac92 100644
--- a/Source/Editor/Windows/Assets/AnimationGraphWindow.cs
+++ b/Source/Editor/Windows/Assets/AnimationGraphWindow.cs
@@ -13,6 +13,7 @@ using FlaxEditor.Viewport.Cameras;
using FlaxEditor.Viewport.Previews;
using FlaxEngine;
using FlaxEngine.GUI;
+using FlaxEngine.Windows.Search;
using Object = FlaxEngine.Object;
// ReSharper disable UnusedMember.Local
@@ -27,7 +28,7 @@ namespace FlaxEditor.Windows.Assets
///
///
///
- public sealed class AnimationGraphWindow : VisjectSurfaceWindow
+ public sealed class AnimationGraphWindow : VisjectSurfaceWindow, ISearchWindow
{
internal static Guid BaseModelId = new Guid(1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
@@ -426,5 +427,8 @@ namespace FlaxEditor.Windows.Assets
base.OnDestroy();
}
+
+ ///
+ public SearchAssetTypes AssetType => SearchAssetTypes.AnimGraph;
}
}
diff --git a/Source/Editor/Windows/Assets/MaterialWindow.cs b/Source/Editor/Windows/Assets/MaterialWindow.cs
index 2c3f05ab9..644b19688 100644
--- a/Source/Editor/Windows/Assets/MaterialWindow.cs
+++ b/Source/Editor/Windows/Assets/MaterialWindow.cs
@@ -8,6 +8,7 @@ using FlaxEditor.Scripting;
using FlaxEditor.Surface;
using FlaxEditor.Viewport.Previews;
using FlaxEngine;
+using FlaxEngine.Windows.Search;
// ReSharper disable UnusedMember.Local
// ReSharper disable UnusedMember.Global
@@ -21,7 +22,7 @@ namespace FlaxEditor.Windows.Assets
///
///
///
- public sealed class MaterialWindow : VisjectSurfaceWindow
+ public sealed class MaterialWindow : VisjectSurfaceWindow, ISearchWindow
{
private readonly ScriptType[] _newParameterTypes =
{
@@ -385,5 +386,8 @@ namespace FlaxEditor.Windows.Assets
return base.SaveToOriginal();
}
+
+ ///
+ public SearchAssetTypes AssetType => SearchAssetTypes.Material;
}
}
diff --git a/Source/Editor/Windows/Assets/ParticleEmitterWindow.cs b/Source/Editor/Windows/Assets/ParticleEmitterWindow.cs
index 226cea0b0..1df505bb3 100644
--- a/Source/Editor/Windows/Assets/ParticleEmitterWindow.cs
+++ b/Source/Editor/Windows/Assets/ParticleEmitterWindow.cs
@@ -8,6 +8,7 @@ using FlaxEditor.Scripting;
using FlaxEditor.Surface;
using FlaxEditor.Viewport.Previews;
using FlaxEngine;
+using FlaxEngine.Windows.Search;
// ReSharper disable UnusedMember.Local
// ReSharper disable UnusedMember.Global
@@ -21,7 +22,7 @@ namespace FlaxEditor.Windows.Assets
///
///
///
- public sealed class ParticleEmitterWindow : VisjectSurfaceWindow
+ public sealed class ParticleEmitterWindow : VisjectSurfaceWindow, ISearchWindow
{
private readonly ScriptType[] _newParameterTypes =
{
@@ -271,5 +272,8 @@ namespace FlaxEditor.Windows.Assets
return base.SaveToOriginal();
}
+
+ ///
+ public SearchAssetTypes AssetType => SearchAssetTypes.ParticleEmitter;
}
}
diff --git a/Source/Editor/Windows/Assets/VisjectFunctionSurfaceWindow.cs b/Source/Editor/Windows/Assets/VisjectFunctionSurfaceWindow.cs
index d296c4af7..2f48fc37f 100644
--- a/Source/Editor/Windows/Assets/VisjectFunctionSurfaceWindow.cs
+++ b/Source/Editor/Windows/Assets/VisjectFunctionSurfaceWindow.cs
@@ -170,6 +170,9 @@ namespace FlaxEditor.Windows.Assets
base.OnAssetLinked();
}
+ ///
+ public Asset SurfaceAsset => Asset;
+
///
public abstract string SurfaceName { get; }
diff --git a/Source/Editor/Windows/Assets/VisualScriptWindow.cs b/Source/Editor/Windows/Assets/VisualScriptWindow.cs
index a54ca837c..1e17afd81 100644
--- a/Source/Editor/Windows/Assets/VisualScriptWindow.cs
+++ b/Source/Editor/Windows/Assets/VisualScriptWindow.cs
@@ -16,6 +16,7 @@ using FlaxEditor.Surface;
using FlaxEngine;
using FlaxEngine.GUI;
using FlaxEngine.Json;
+using FlaxEngine.Windows.Search;
#pragma warning disable 649
@@ -30,7 +31,7 @@ namespace FlaxEditor.Windows.Assets
///
///
///
- public sealed class VisualScriptWindow : AssetEditorWindowBase, IVisjectSurfaceWindow
+ public sealed class VisualScriptWindow : AssetEditorWindowBase, IVisjectSurfaceWindow, ISearchWindow
{
private struct BreakpointData
{
@@ -238,6 +239,9 @@ namespace FlaxEditor.Windows.Assets
b.Enabled = window._canEdit;
b.TooltipText = "Changes parameter type to a dictionary.";
}
+
+ menu.AddSeparator();
+ menu.AddButton("Find references...", () => OnFindReferences(index));
}
private void OnChangeType(Action itemClicked)
@@ -257,6 +261,13 @@ namespace FlaxEditor.Windows.Assets
cm.SortChildren();
cm.Show(window, window.PointFromScreen(Input.MouseScreenPosition));
}
+
+ private void OnFindReferences(int index)
+ {
+ var window = (VisualScriptWindow)Values[0];
+ var param = window.Surface.Parameters[index];
+ Editor.Instance.ContentFinding.ShowSearch(window, '\"' + window.Asset.ScriptTypeName + '.' + param.Name + '\"');
+ }
}
private sealed class PropertiesProxy
@@ -1097,6 +1108,9 @@ namespace FlaxEditor.Windows.Assets
Surface.FocusNode(node);
}
+ ///
+ public Asset SurfaceAsset => Asset;
+
///
public string SurfaceName => "Visual Script";
@@ -1431,5 +1445,8 @@ namespace FlaxEditor.Windows.Assets
///
public VisjectSurface VisjectSurface => _surface;
+
+ ///
+ public SearchAssetTypes AssetType => SearchAssetTypes.VisualScript;
}
}
diff --git a/Source/Editor/Windows/Search/ContentSearchWindow.cs b/Source/Editor/Windows/Search/ContentSearchWindow.cs
index d9ef1d335..d8d061112 100644
--- a/Source/Editor/Windows/Search/ContentSearchWindow.cs
+++ b/Source/Editor/Windows/Search/ContentSearchWindow.cs
@@ -19,6 +19,54 @@ using FlaxEngine.GUI;
namespace FlaxEngine.Windows.Search
{
+ ///
+ /// Content searching asset types.
+ ///
+ [Flags]
+ public enum SearchAssetTypes
+ {
+ ///
+ /// The none.
+ ///
+ None = 0,
+
+ ///
+ /// The visual script.
+ ///
+ VisualScript = 1 << 0,
+
+ ///
+ /// The material.
+ ///
+ Material = 1 << 1,
+
+ ///
+ /// The animation graph.
+ ///
+ AnimGraph = 1 << 2,
+
+ ///
+ /// The particle emitter.
+ ///
+ ParticleEmitter = 1 << 3,
+
+ ///
+ /// All types.
+ ///
+ All = VisualScript | Material | AnimGraph | ParticleEmitter,
+ }
+
+ ///
+ /// Interface for Editor windows to customize search.
+ ///
+ public interface ISearchWindow
+ {
+ ///
+ /// Gets the type of the asset for the search.
+ ///
+ SearchAssetTypes AssetType { get; }
+ }
+
///
/// The content searching window. Allows to search inside Visual Scripts, Materials, Particles and other assets.
///
@@ -45,22 +93,11 @@ namespace FlaxEngine.Windows.Search
AllAssets,
}
- ///
- /// Content searching asset types.
- ///
- [Flags]
- public enum SearchAssetTypes
- {
- None = 0,
- VisualScript = 1 << 0,
- Material = 1 << 1,
- AnimGraph = 1 << 2,
- ParticleEmitter = 1 << 3,
- All = VisualScript | Material | AnimGraph | ParticleEmitter,
- }
-
private sealed class SearchSurfaceContext : ISurfaceContext
{
+ ///
+ public Asset SurfaceAsset { get; set; }
+
///
public string SurfaceName => string.Empty;
@@ -223,6 +260,7 @@ namespace FlaxEngine.Windows.Search
if (_loadingLabel.Visible)
_loadingLabel.Text = string.Format("Searching {0}%...", (int)_progress);
+ _resultsTreeRoot.Expand(true);
lock (_pendingResults)
{
@@ -488,6 +526,7 @@ namespace FlaxEngine.Windows.Search
// Load Visject surface from data
if (surfaceData == null || surfaceData.Length == 0)
return;
+ _searchSurfaceContext.SurfaceAsset = asset;
_searchSurfaceContext.SurfaceData = surfaceData;
if (_visjectSurfaceContext.Load())
{
@@ -522,32 +561,41 @@ namespace FlaxEngine.Windows.Search
}
// Search nodes
+ var newTreeNodes = new List();
foreach (var node in _visjectSurfaceContext.Nodes)
{
- SearchResultTreeNode nodeTreeNode = null;
+ newTreeNodes.Clear();
if (node.Values != null)
{
foreach (var value in node.Values)
{
SearchVisjectMatch(value, (matchedValue, matchedText) =>
{
- AddAssetSearchResult(ref assetTreeNode, asset);
- if (nodeTreeNode == null)
- nodeTreeNode = new SearchResultTreeNode
- {
- Text = node.Title,
- TooltipText = node.TooltipText,
- Tag = node.ID,
- Navigate = OnNavigateVisjectNode,
- Parent = assetTreeNode,
- };
var valueTreeNode = AddVisjectSearchResult(matchedValue, matchedText, node.Archetype.ConnectionsHints);
valueTreeNode.Tag = node.ID;
valueTreeNode.Navigate = OnNavigateVisjectNode;
- valueTreeNode.Parent = nodeTreeNode;
+ newTreeNodes.Add(valueTreeNode);
});
}
}
+ var nodeSearchText = node.ContentSearchText;
+
+ if (newTreeNodes.Count != 0 || (nodeSearchText != null && IsSearchMatch(ref nodeSearchText)))
+ {
+ AddAssetSearchResult(ref assetTreeNode, asset);
+ var nodeTreeNode = new SearchResultTreeNode
+ {
+ Text = node.Title,
+ TooltipText = node.TooltipText,
+ Tag = node.ID,
+ Navigate = OnNavigateVisjectNode,
+ Parent = assetTreeNode,
+ };
+ foreach (var newTreeNode in newTreeNodes)
+ {
+ newTreeNode.Parent = nodeTreeNode;
+ }
+ }
}
if (assetTreeNode != null)