diff --git a/Source/Editor/Surface/VisjectSurfaceWindow.cs b/Source/Editor/Surface/VisjectSurfaceWindow.cs
index 181ca2991..e67d04b1b 100644
--- a/Source/Editor/Surface/VisjectSurfaceWindow.cs
+++ b/Source/Editor/Surface/VisjectSurfaceWindow.cs
@@ -338,6 +338,11 @@ namespace FlaxEditor.Surface
//new LimitAttribute(float.MinValue, float.MaxValue, 0.1f),
};
+ ///
+ /// True if show only public properties, otherwise will display all properties.
+ ///
+ protected bool ShowOnlyPublic = true;
+
///
public override DisplayStyle Style => DisplayStyle.InlineIntoParent;
@@ -367,7 +372,7 @@ namespace FlaxEditor.Surface
for (int i = 0; i < parameters.Count; i++)
{
var p = parameters[i];
- if (!p.IsPublic)
+ if (!p.IsPublic && ShowOnlyPublic)
continue;
var pIndex = i;
@@ -421,6 +426,8 @@ namespace FlaxEditor.Surface
Tag = pIndex,
Drag = OnDragParameter
};
+ if (!p.IsPublic)
+ propertyLabel.TextColor = propertyLabel.TextColor.RGBMultiplied(0.7f);
var tooltip = (TooltipAttribute)attributes.FirstOrDefault(x => x is TooltipAttribute);
propertyLabel.MouseLeftDoubleClick += (label, location) => StartParameterRenaming(pIndex, label);
propertyLabel.SetupContextMenu += OnPropertyLabelSetupContextMenu;
@@ -491,6 +498,7 @@ namespace FlaxEditor.Surface
menu.AddButton("Rename", () => StartParameterRenaming(index, label));
menu.AddButton("Edit attributes...", () => EditAttributesParameter(index, label));
menu.AddButton("Delete", () => DeleteParameter(index));
+ OnParamContextMenu(index, menu);
}
private void StartParameterRenaming(int index, Control label)
@@ -556,6 +564,15 @@ namespace FlaxEditor.Surface
window.VisjectSurface.Undo.AddAction(action);
action.Do();
}
+
+ ///
+ /// Called to display additional context options for a parameter.
+ ///
+ /// The zero-based parameter index.
+ /// The context menu.
+ protected virtual void OnParamContextMenu(int index, FlaxEditor.GUI.ContextMenu.ContextMenu menu)
+ {
+ }
}
///
diff --git a/Source/Editor/Windows/Assets/VisualScriptWindow.cs b/Source/Editor/Windows/Assets/VisualScriptWindow.cs
index 95e730bea..729fc71cd 100644
--- a/Source/Editor/Windows/Assets/VisualScriptWindow.cs
+++ b/Source/Editor/Windows/Assets/VisualScriptWindow.cs
@@ -38,6 +38,63 @@ namespace FlaxEditor.Windows.Assets
public bool Enabled;
}
+ private sealed class EditParamAccessAction : IUndoAction
+ {
+ public IVisjectSurfaceWindow Window;
+ public int Index;
+ public bool Before;
+ public bool After;
+
+ public string ActionString => "Edit parameter access";
+
+ public void Do()
+ {
+ Set(After);
+ }
+
+ public void Undo()
+ {
+ Set(Before);
+ }
+
+ private void Set(bool value)
+ {
+ var param = Window.VisjectSurface.Parameters[Index];
+ param.IsPublic = value;
+ Window.VisjectSurface.OnParamEdited(param);
+ }
+
+ public void Dispose()
+ {
+ Window = null;
+ }
+ }
+
+ private sealed class VisualParametersEditor : ParametersEditor
+ {
+ public VisualParametersEditor()
+ {
+ ShowOnlyPublic = false;
+ }
+
+ protected override void OnParamContextMenu(int index, ContextMenu menu)
+ {
+ var window = (VisualScriptWindow)Values[0];
+ var param = window.Surface.Parameters[index];
+
+ // Parameter access level editing
+ var cmAccess = menu.AddChildMenu("Access");
+ {
+ var b = cmAccess.ContextMenu.AddButton("Public", () => window.SetParamAccess(index, true));
+ b.Checked = param.IsPublic;
+ b.Enabled = window._canEdit;
+ b = cmAccess.ContextMenu.AddButton("Private", () => window.SetParamAccess(index, false));
+ b.Checked = !param.IsPublic;
+ b.Enabled = window._canEdit;
+ }
+ }
+ }
+
private sealed class PropertiesProxy
{
[EditorOrder(0), EditorDisplay("Options"), CustomEditor(typeof(OptionsEditor)), NoSerialize]
@@ -58,7 +115,7 @@ namespace FlaxEditor.Windows.Assets
[EditorOrder(900), CustomEditor(typeof(FunctionsEditor)), NoSerialize]
public VisualScriptWindow Window1;
- [EditorOrder(1000), EditorDisplay("Parameters"), CustomEditor(typeof(ParametersEditor)), NoSerialize]
+ [EditorOrder(1000), EditorDisplay("Parameters"), CustomEditor(typeof(VisualParametersEditor)), NoSerialize]
public VisualScriptWindow Window;
[HideInEditor]
@@ -991,6 +1048,22 @@ namespace FlaxEditor.Windows.Assets
UpdateToolstrip();
}
+ private void SetParamAccess(int index, bool isPublic)
+ {
+ var param = Surface.Parameters[index];
+ if (param.IsPublic == isPublic)
+ return;
+ var action = new EditParamAccessAction
+ {
+ Window = this,
+ Index = index,
+ Before = param.IsPublic,
+ After = isPublic,
+ };
+ _undo.AddAction(action);
+ action.Do();
+ }
+
///
public override void OnPlayBeginning()
{