diff --git a/Source/Editor/Options/InterfaceOptions.cs b/Source/Editor/Options/InterfaceOptions.cs index 286ec720d..d62dc8510 100644 --- a/Source/Editor/Options/InterfaceOptions.cs +++ b/Source/Editor/Options/InterfaceOptions.cs @@ -372,7 +372,7 @@ namespace FlaxEditor.Options /// Gets or sets the visject connection curvature. /// [DefaultValue(true)] - [EditorDisplay("Visject"), EditorOrder(550)] + [EditorDisplay("Visject"), EditorOrder(550), Tooltip("Shows/hides the description panel in the visual scripting context menu.")] public bool VisualScriptingDescriptionPanel { get; set; } = true; private static FontAsset DefaultFont => FlaxEngine.Content.LoadAsyncInternal(EditorAssets.PrimaryFont); diff --git a/Source/Editor/Surface/AnimGraphSurface.cs b/Source/Editor/Surface/AnimGraphSurface.cs index ea0d9d32f..4e8b6f11e 100644 --- a/Source/Editor/Surface/AnimGraphSurface.cs +++ b/Source/Editor/Surface/AnimGraphSurface.cs @@ -197,7 +197,6 @@ namespace FlaxEditor.Surface { Groups = StateMachineGroupArchetypes, CanSpawnNode = (_, _) => true, - Style = Style, }); _cmStateMachineMenu.ShowExpanded = true; } @@ -215,7 +214,6 @@ namespace FlaxEditor.Surface CanSpawnNode = CanUseNodeType, ParametersGetter = null, CustomNodesGroup = GetCustomNodes(), - Style = Style, }); _cmStateMachineTransitionMenu.AddGroup(StateMachineTransitionGroupArchetype, false); } diff --git a/Source/Editor/Surface/Archetypes/Constants.cs b/Source/Editor/Surface/Archetypes/Constants.cs index 8cce34332..59b554e6b 100644 --- a/Source/Editor/Surface/Archetypes/Constants.cs +++ b/Source/Editor/Surface/Archetypes/Constants.cs @@ -7,8 +7,6 @@ using Real = System.Single; #endif using System; -using System.Collections; -using System.Collections.Generic; using System.Linq; using FlaxEditor.CustomEditors.Editors; using FlaxEditor.GUI; @@ -468,7 +466,7 @@ namespace FlaxEditor.Surface.Archetypes internal static void GetInputOutputDescription(NodeArchetype nodeArch, out (string, ScriptType)[] inputs, out (string, ScriptType)[] outputs) { inputs = null; - outputs = [("", new ScriptType(typeof(Dictionary)))]; + outputs = [("", new ScriptType(typeof(System.Collections.Generic.Dictionary)))]; } } diff --git a/Source/Editor/Surface/Archetypes/Packing.cs b/Source/Editor/Surface/Archetypes/Packing.cs index 5e84d615a..88ed6a64d 100644 --- a/Source/Editor/Surface/Archetypes/Packing.cs +++ b/Source/Editor/Surface/Archetypes/Packing.cs @@ -248,17 +248,24 @@ namespace FlaxEditor.Surface.Archetypes internal static void GetInputOutputDescription(NodeArchetype nodeArch, out (string, ScriptType)[] inputs, out (string, ScriptType)[] outputs) { - var type = TypeUtils.GetType((string)nodeArch.DefaultValues[0]); - outputs = [(type.Name, type)]; - - var fields = type.GetMembers(BindingFlags.Public | BindingFlags.Instance).Where(x => x.IsField).ToArray(); - var fieldsLength = fields.Length; - inputs = new (string, ScriptType)[fieldsLength]; - for (var i = 0; i < fieldsLength; i++) + var typeName = (string)nodeArch.DefaultValues[0]; + var type = TypeUtils.GetType(typeName); + if (type) { - var field = fields[i]; - inputs[i] = (field.Name, field.ValueType); + var fields = type.GetMembers(BindingFlags.Public | BindingFlags.Instance).Where(x => x.IsField).ToArray(); + var fieldsLength = fields.Length; + inputs = new (string, ScriptType)[fieldsLength]; + for (var i = 0; i < fieldsLength; i++) + { + var field = fields[i]; + inputs[i] = (field.Name, field.ValueType); + } + + outputs = [(type.Name, type)]; } + + inputs = null; + outputs = null; } } @@ -301,17 +308,23 @@ namespace FlaxEditor.Surface.Archetypes internal static void GetInputOutputDescription(NodeArchetype nodeArch, out (string, ScriptType)[] inputs, out (string, ScriptType)[] outputs) { - var type = TypeUtils.GetType((string)nodeArch.DefaultValues[0]); - inputs = [(type.Name, type)]; - - var fields = type.GetMembers(BindingFlags.Public | BindingFlags.Instance).Where(x => x.IsField).ToArray(); - var fieldsLength = fields.Length; - outputs = new (string, ScriptType)[fieldsLength]; - for (var i = 0; i < fieldsLength; i++) + var typeName = (string)nodeArch.DefaultValues[0]; + var type = TypeUtils.GetType(typeName); + if (type) { - var field = fields[i]; - outputs[i] = (field.Name, field.ValueType); + inputs = [(type.Name, type)]; + + var fields = type.GetMembers(BindingFlags.Public | BindingFlags.Instance).Where(x => x.IsField).ToArray(); + var fieldsLength = fields.Length; + outputs = new (string, ScriptType)[fieldsLength]; + for (var i = 0; i < fieldsLength; i++) + { + var field = fields[i]; + outputs[i] = (field.Name, field.ValueType); + } } + inputs = null; + outputs = null; } } diff --git a/Source/Editor/Surface/ContextMenu/VisjectCM.cs b/Source/Editor/Surface/ContextMenu/VisjectCM.cs index b30e726dd..d6dd852b4 100644 --- a/Source/Editor/Surface/ContextMenu/VisjectCM.cs +++ b/Source/Editor/Surface/ContextMenu/VisjectCM.cs @@ -2,14 +2,11 @@ using System; using System.Collections.Generic; -using System.IO; using System.Linq; -using System.Reflection; using System.Text.RegularExpressions; using FlaxEditor.GUI.ContextMenu; using FlaxEditor.GUI.Input; using FlaxEditor.Scripting; -using FlaxEditor.Surface.Archetypes; using FlaxEngine; using FlaxEngine.GUI; using FlaxEngine.Utilities; @@ -62,13 +59,12 @@ namespace FlaxEditor.Surface.ContextMenu private bool _descriptionPanelVisible; private readonly Panel _descriptionPanel; private readonly Panel _descriptionPanelSeparator; - private readonly Image _descriptionClassImage; + private readonly Image _descriptionDeclaringClassImage; private readonly Label _descriptionSignatureLabel; private readonly Label _descriptionLabel; - private readonly SurfaceStyle _surfaceStyle; private readonly VerticalPanel _descriptionInputPanel; private readonly VerticalPanel _descriptionOutputPanel; - + private readonly SurfaceStyle _surfaceStyle; private VisjectCMItem _selectedItem; /// @@ -251,7 +247,7 @@ namespace FlaxEditor.Surface.ContextMenu }; var spriteHandle = info.Style.Icons.BoxClose; - _descriptionClassImage = new Image(8, 12, 20, 20) + _descriptionDeclaringClassImage = new Image(8, 12, 20, 20) { Parent = _descriptionPanel, Brush = new SpriteBrush(spriteHandle), @@ -816,12 +812,12 @@ namespace FlaxEditor.Surface.ContextMenu HideDescriptionPanel(); return; } - + Profiler.BeginEvent("VisjectCM.SetDescriptionPanelArchetype"); - + _descriptionInputPanel.RemoveChildren(); _descriptionOutputPanel.RemoveChildren(); - + ScriptType declaringType; if (archetype.Tag is ScriptMemberInfo memberInfo) { @@ -844,7 +840,7 @@ namespace FlaxEditor.Surface.ContextMenu else AddInputOutputElement(archetype, memberInfo.ValueType, true, $"Return ({memberInfo.ValueType.Name})"); } - + for(int i = 0; i < memberInfo.ParametersCount; i++) { var param = memberInfo.GetParameters()[i]; @@ -858,13 +854,13 @@ namespace FlaxEditor.Surface.ContextMenu if (archetype.GetInputOutputDescription != null) { - archetype.GetInputOutputDescription.Invoke(archetype, out (string, ScriptType)[] inputs, out (string, ScriptType)[] outputs); + archetype.GetInputOutputDescription.Invoke(archetype, out (string Name, ScriptType Type)[] inputs, out (string Name, ScriptType Type)[] outputs); if (inputs != null) { for (int i = 0; i < inputs.Length; i++) { - AddInputOutputElement(archetype, inputs[i].Item2, false, $"{inputs[i].Item1} ({inputs[i].Item2.Name})"); + AddInputOutputElement(archetype, inputs[i].Type, false, $"{inputs[i].Name} ({inputs[i].Type.Name})"); } } @@ -872,7 +868,7 @@ namespace FlaxEditor.Surface.ContextMenu { for (int i = 0; i < outputs.Length; i++) { - AddInputOutputElement(archetype, outputs[i].Item2, true, $"{outputs[i].Item1} ({outputs[i].Item2.Name})"); + AddInputOutputElement(archetype, outputs[i].Type, true, $"{outputs[i].Name} ({outputs[i].Type.Name})"); } } } @@ -880,22 +876,22 @@ namespace FlaxEditor.Surface.ContextMenu { foreach (var element in archetype.Elements) { - if (element.Type is NodeElementType.Input or NodeElementType.Output) - { - bool isOutput = element.Type == NodeElementType.Output; - if (element.ConnectionsType == null) - AddInputOutputElement(archetype, element.ConnectionsType, isOutput, $"{element.Text} ({archetype.ConnectionsHints.ToString()})"); - else - AddInputOutputElement(archetype, element.ConnectionsType, isOutput, $"{element.Text} ({element.ConnectionsType.Name})"); - } + if (element.Type is not (NodeElementType.Input or NodeElementType.Output)) + continue; + + bool isOutput = element.Type == NodeElementType.Output; + if (element.ConnectionsType == null) + AddInputOutputElement(archetype, element.ConnectionsType, isOutput, $"{element.Text} ({archetype.ConnectionsHints.ToString()})"); + else + AddInputOutputElement(archetype, element.ConnectionsType, isOutput, $"{element.Text} ({element.ConnectionsType.Name})"); } } } _surfaceStyle.GetConnectionColor(declaringType, archetype.ConnectionsHints, out var declaringTypeColor); - _descriptionClassImage.Color = declaringTypeColor; - _descriptionClassImage.MouseOverColor = declaringTypeColor; - + _descriptionDeclaringClassImage.Color = declaringTypeColor; + _descriptionDeclaringClassImage.MouseOverColor = declaringTypeColor; + float panelHeight = _descriptionSignatureLabel.Height; if (string.IsNullOrEmpty(archetype.Description)) @@ -911,21 +907,21 @@ namespace FlaxEditor.Surface.ContextMenu } _descriptionPanelSeparator.Y = _descriptionLabel.Bounds.Bottom + 8f; - + panelHeight += _descriptionLabel.Height + 32f; _descriptionInputPanel.Y = panelHeight; _descriptionOutputPanel.Y = panelHeight; panelHeight += Mathf.Max(_descriptionInputPanel.Height, _descriptionOutputPanel.Height); - + // Forcing the description panel to at least have a minimum height to not make the window size change too much in order to reduce jittering // TODO: Remove the Mathf.Max and just set the height to panelHeight once the window jitter issue is fixed - Nils _descriptionPanel.Height = Mathf.Max(135f, panelHeight); Height = 400 + _descriptionPanel.Height; UpdateWindowSize(); _descriptionPanelVisible = true; - + Profiler.EndEvent(); } @@ -962,7 +958,7 @@ namespace FlaxEditor.Surface.ContextMenu elementPanel.AddChild(elementText); elementPanel.Height = elementText.Height; } - + /// /// Hides the description panel and resets the context menu to its original size /// diff --git a/Source/Editor/Surface/NodeArchetype.cs b/Source/Editor/Surface/NodeArchetype.cs index 63d731b72..609b7b5f7 100644 --- a/Source/Editor/Surface/NodeArchetype.cs +++ b/Source/Editor/Surface/NodeArchetype.cs @@ -97,7 +97,7 @@ namespace FlaxEditor.Surface /// /// Gets description of inputs and outputs of the archetype. Used for special cases for the description panel. /// - public delegate void GetElementsDescriptionFunc(NodeArchetype nodeArch, out (string, ScriptType)[] inputs, out (string, ScriptType)[] outputs); + public delegate void GetElementsDescriptionFunc(NodeArchetype nodeArch, out (string Name, ScriptType Type)[] inputs, out (string Name, ScriptType Type)[] outputs); /// /// Unique node type ID within a single group. diff --git a/Source/Editor/Surface/SurfaceUtils.cs b/Source/Editor/Surface/SurfaceUtils.cs index 6bc834b0a..ad77aa510 100644 --- a/Source/Editor/Surface/SurfaceUtils.cs +++ b/Source/Editor/Surface/SurfaceUtils.cs @@ -468,7 +468,6 @@ namespace FlaxEditor.Surface sb.Append('.'); sb.Append(name); - // Is a method and not a property if (member.IsMethod) { sb.Append('('); @@ -512,7 +511,7 @@ namespace FlaxEditor.Surface return GetVisualScriptMemberShortDescription(property[0]); } } - + return Editor.Instance.CodeDocs.GetTooltip(member); } diff --git a/Source/Editor/Surface/VisjectSurfaceContext.Serialization.cs b/Source/Editor/Surface/VisjectSurfaceContext.Serialization.cs index 97122f872..7ddbc72db 100644 --- a/Source/Editor/Surface/VisjectSurfaceContext.Serialization.cs +++ b/Source/Editor/Surface/VisjectSurfaceContext.Serialization.cs @@ -51,7 +51,7 @@ namespace FlaxEditor.Surface { TypeID = originalNodeId, Title = "Missing Node :(", - Signature = ":(", + Signature = "Missing Node :(", Description = ":(", Flags = NodeFlags.AllGraphs, Size = new Float2(200, 70),