diff --git a/Source/Editor/Surface/Archetypes/Parameters.cs b/Source/Editor/Surface/Archetypes/Parameters.cs
index 3383e7662..905f793c9 100644
--- a/Source/Editor/Surface/Archetypes/Parameters.cs
+++ b/Source/Editor/Surface/Archetypes/Parameters.cs
@@ -22,15 +22,97 @@ namespace FlaxEditor.Surface.Archetypes
[HideInEditor]
public static class Parameters
{
+ ///
+ /// Surface node type for parameters group Get/Set nodes.
+ ///
+ ///
+ public abstract class SurfaceNodeParamsBase : SurfaceNode
+ {
+ ///
+ /// The combobox for picking parameter.
+ ///
+ protected ComboBoxElement _combobox;
+
+ ///
+ /// Fag used to block layout updated when updating node.
+ ///
+ protected bool _isUpdateLocked;
+
+ ///
+ protected SurfaceNodeParamsBase(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch)
+ : base(id, context, nodeArch, groupArch)
+ {
+ }
+
+ ///
+ /// Gets the selected parameter.
+ ///
+ /// Surface parameter object or null if nothing selected or cannot find it.
+ protected SurfaceParameter GetSelected()
+ {
+ if (Surface != null)
+ return Surface.GetParameter(_combobox.SelectedItem);
+ return Context.GetParameter((Guid)Values[0]);
+ }
+
+ ///
+ /// Updates the combo box.
+ ///
+ protected void UpdateCombo()
+ {
+ if (_isUpdateLocked)
+ return;
+ _isUpdateLocked = true;
+ if (_combobox == null)
+ {
+ _combobox = GetChild();
+ _combobox.SelectedIndexChanged += OnSelectedChanged;
+ }
+ string toSelect = null;
+ Guid loadedSelected = (Guid)Values[0];
+ _combobox.ClearItems();
+ var parameters = Surface.Parameters;
+ for (int i = 0; i < parameters.Count; i++)
+ {
+ var param = parameters[i];
+ if (!param.IsPublic && !Surface.CanShowPrivateParameters)
+ continue;
+ _combobox.AddItem(param.Name);
+ if (param.ID == loadedSelected)
+ toSelect = param.Name;
+ }
+ _combobox.SelectedItem = toSelect;
+ _isUpdateLocked = false;
+ }
+
+ private void OnSelectedChanged(ComboBox cb)
+ {
+ if (_isUpdateLocked)
+ return;
+ var selected = GetSelected();
+ var selectedID = selected?.ID ?? Guid.Empty;
+ if (selectedID != (Guid)Values[0])
+ Set(selected, ref selectedID);
+ }
+
+ ///
+ /// Sets the selected parameter.
+ ///
+ /// Parameter.
+ /// Parameter identifier.
+ protected virtual void Set(SurfaceParameter selected, ref Guid selectedID)
+ {
+ SetValue(0, selectedID);
+ }
+ }
+
///
/// Surface node type for parameters group Get node.
///
///
- public class SurfaceNodeParamsGet : SurfaceNode, IParametersDependantNode
+ public class SurfaceNodeParamsGet : SurfaceNodeParamsBase, IParametersDependantNode
{
- private ComboBoxElement _combobox;
private readonly List _dynamicChildren = new List();
- private bool _isUpdateLocked;
private ScriptType _layoutType;
private NodeElementArchetype[] _layoutElements;
@@ -306,49 +388,6 @@ namespace FlaxEditor.Surface.Archetypes
UpdateTitle();
}
- private void UpdateCombo()
- {
- if (_isUpdateLocked)
- return;
- _isUpdateLocked = true;
- if (_combobox == null)
- {
- _combobox = (ComboBoxElement)_children[0];
- _combobox.SelectedIndexChanged += OnSelectedChanged;
- }
- int toSelect = -1;
- Guid loadedSelected = (Guid)Values[0];
- _combobox.ClearItems();
- for (int i = 0; i < Surface.Parameters.Count; i++)
- {
- var param = Surface.Parameters[i];
- _combobox.AddItem(param.Name);
- if (param.ID == loadedSelected)
- toSelect = i;
- }
- _combobox.SelectedIndex = toSelect;
- _isUpdateLocked = false;
- }
-
- private void OnSelectedChanged(ComboBox cb)
- {
- if (_isUpdateLocked)
- return;
- var selected = GetSelected();
- var selectedID = selected?.ID ?? Guid.Empty;
- SetValue(0, selectedID);
- }
-
- private SurfaceParameter GetSelected()
- {
- 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()
{
for (int i = 0; i < _dynamicChildren.Count; i++)
@@ -463,15 +502,19 @@ namespace FlaxEditor.Surface.Archetypes
else if (!_isUpdateLocked)
{
_isUpdateLocked = true;
- int toSelect = -1;
+ string toSelect = null;
Guid loadedSelected = (Guid)Values[0];
- for (int i = 0; i < Surface.Parameters.Count; i++)
+ var parameters = Surface.Parameters;
+ for (int i = 0; i < parameters.Count; i++)
{
- var param = Surface.Parameters[i];
+ var param = parameters[i];
if (param.ID == loadedSelected)
- toSelect = i;
+ {
+ toSelect = param.Name;
+ break;
+ }
}
- _combobox.SelectedIndex = toSelect;
+ _combobox.SelectedItem = toSelect;
_isUpdateLocked = false;
}
UpdateLayout();
@@ -817,66 +860,23 @@ namespace FlaxEditor.Surface.Archetypes
/// Surface node type for parameters group Set node.
///
///
- public class SurfaceNodeParamsSet : SurfaceNode, IParametersDependantNode
+ public class SurfaceNodeParamsSet : SurfaceNodeParamsBase, IParametersDependantNode
{
- private ComboBoxElement _combobox;
- private bool _isUpdateLocked;
-
///
public SurfaceNodeParamsSet(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch)
: base(id, context, nodeArch, groupArch)
{
}
- private void UpdateCombo()
+ ///
+ protected override void Set(SurfaceParameter selected, ref Guid selectedID)
{
- if (_isUpdateLocked)
- return;
- _isUpdateLocked = true;
- if (_combobox == null)
+ SetValues(new[]
{
- _combobox = GetChild();
- _combobox.SelectedIndexChanged += OnSelectedChanged;
- }
- int toSelect = -1;
- Guid loadedSelected = (Guid)Values[0];
- _combobox.ClearItems();
- for (int i = 0; i < Surface.Parameters.Count; i++)
- {
- var param = Surface.Parameters[i];
- _combobox.AddItem(param.Name);
- if (param.ID == loadedSelected)
- toSelect = i;
- }
- _combobox.SelectedIndex = toSelect;
- _isUpdateLocked = false;
- }
-
- private void OnSelectedChanged(ComboBox cb)
- {
- if (_isUpdateLocked)
- return;
- var selected = GetSelected();
- var selectedID = selected?.ID ?? Guid.Empty;
- if (selectedID != (Guid)Values[0])
- {
- SetValues(new[]
- {
- selectedID,
- selected != null ? TypeUtils.GetDefaultValue(selected.Type) : null,
- });
- UpdateUI();
- }
- }
-
- private SurfaceParameter GetSelected()
- {
- if (Surface != null)
- {
- var selectedIndex = _combobox.SelectedIndex;
- return selectedIndex >= 0 && selectedIndex < Surface.Parameters.Count ? Surface.Parameters[selectedIndex] : null;
- }
- return Context.GetParameter((Guid)Values[0]);
+ selectedID,
+ selected != null ? TypeUtils.GetDefaultValue(selected.Type) : null,
+ });
+ UpdateUI();
}
///
diff --git a/Source/Editor/Surface/VisjectSurface.cs b/Source/Editor/Surface/VisjectSurface.cs
index e3bb94bcc..c4a8d31d3 100644
--- a/Source/Editor/Surface/VisjectSurface.cs
+++ b/Source/Editor/Surface/VisjectSurface.cs
@@ -583,6 +583,11 @@ namespace FlaxEditor.Surface
///
public virtual bool CanSetParameters => false;
+ ///
+ /// Gets a value indicating whether surface private parameters can be used, otherwise they will remain hidden.
+ ///
+ public virtual bool CanShowPrivateParameters => false;
+
///
/// True of the context menu should make use of a description panel drawn at the bottom of the menu
///
diff --git a/Source/Editor/Surface/VisjectSurfaceContext.cs b/Source/Editor/Surface/VisjectSurfaceContext.cs
index 0d10aa230..560a7c1d6 100644
--- a/Source/Editor/Surface/VisjectSurfaceContext.cs
+++ b/Source/Editor/Surface/VisjectSurfaceContext.cs
@@ -254,9 +254,10 @@ namespace FlaxEditor.Surface
public SurfaceParameter GetParameter(Guid id)
{
SurfaceParameter result = null;
- for (int i = 0; i < Parameters.Count; i++)
+ var parameters = Parameters;
+ for (int i = 0; i < parameters.Count; i++)
{
- var parameter = Parameters[i];
+ var parameter = parameters[i];
if (parameter.ID == id)
{
result = parameter;
@@ -274,9 +275,10 @@ namespace FlaxEditor.Surface
public SurfaceParameter GetParameter(string name)
{
SurfaceParameter result = null;
- for (int i = 0; i < Parameters.Count; i++)
+ var parameters = Parameters;
+ for (int i = 0; i < parameters.Count; i++)
{
- var parameter = Parameters[i];
+ var parameter = parameters[i];
if (parameter.Name == name)
{
result = parameter;
diff --git a/Source/Editor/Surface/VisualScriptSurface.cs b/Source/Editor/Surface/VisualScriptSurface.cs
index 2f70ee340..57aa29d67 100644
--- a/Source/Editor/Surface/VisualScriptSurface.cs
+++ b/Source/Editor/Surface/VisualScriptSurface.cs
@@ -187,6 +187,9 @@ namespace FlaxEditor.Surface
///
public override bool CanSetParameters => true;
+ ///
+ public override bool CanShowPrivateParameters => true;
+
///
public override bool UseContextMenuDescriptionPanel => true;