diff --git a/Source/Editor/Surface/VisualScriptSurface.cs b/Source/Editor/Surface/VisualScriptSurface.cs index 18a4695aa..90312c6b7 100644 --- a/Source/Editor/Surface/VisualScriptSurface.cs +++ b/Source/Editor/Surface/VisualScriptSurface.cs @@ -62,6 +62,19 @@ namespace FlaxEditor.Surface return true; } + private string GetBoxDebuggerTooltip(ref Editor.VisualScriptLocal local) + { + if (string.IsNullOrEmpty(local.ValueTypeName)) + { + if (string.IsNullOrEmpty(local.Value)) + return string.Empty; + return local.Value; + } + if (string.IsNullOrEmpty(local.Value)) + return $"({local.ValueTypeName})"; + return $"{local.Value}\n({local.ValueTypeName})"; + } + /// public override void OnNodeBreakpointEdited(SurfaceNode node) { @@ -95,7 +108,7 @@ namespace FlaxEditor.Surface ref var local = ref state.Locals[i]; if (local.BoxId == box.ID && local.NodeId == box.ParentNode.ID) { - text = $"{local.Value ?? string.Empty} ({local.ValueTypeName})"; + text = GetBoxDebuggerTooltip(ref local); return true; } } @@ -107,7 +120,7 @@ namespace FlaxEditor.Surface ref var local = ref state.Locals[i]; if (local.BoxId == connectedBox.ID && local.NodeId == connectedBox.ParentNode.ID) { - text = $"{local.Value ?? string.Empty} ({local.ValueTypeName})"; + text = GetBoxDebuggerTooltip(ref local); return true; } } @@ -125,7 +138,31 @@ namespace FlaxEditor.Surface var script = ((Windows.Assets.VisualScriptWindow)box.Surface.Owner).Asset; if (Editor.EvaluateVisualScriptLocal(script, ref local)) { - text = $"{local.Value ?? string.Empty} ({local.ValueTypeName})"; + // Check if got no value (null) + if (string.IsNullOrEmpty(local.ValueTypeName) && string.Equals(local.Value, "null", StringComparison.Ordinal)) + { + var connections = box.Connections; + if (connections.Count == 0 && box.Archetype.ValueIndex >= 0 && box.ParentNode.Values != null && box.Archetype.ValueIndex < box.ParentNode.Values.Length) + { + // Special case when there is no value but the box has no connection and uses + var defaultValue = box.ParentNode.Values[box.Archetype.ValueIndex]; + if (defaultValue != null) + { + local.Value = defaultValue.ToString(); + local.ValueTypeName = defaultValue.GetType().FullName; + } + } + else if (connections.Count == 1) + { + // Special case when there is no value but the box has a connection with valid value to try to use it instead + box = connections[0]; + local.NodeId = box.ParentNode.ID; + local.BoxId = box.ID; + Editor.EvaluateVisualScriptLocal(script, ref local); + } + } + + text = GetBoxDebuggerTooltip(ref local); return true; } } diff --git a/Source/Engine/Content/Assets/VisualScript.cpp b/Source/Engine/Content/Assets/VisualScript.cpp index 9748ba60c..320116d60 100644 --- a/Source/Engine/Content/Assets/VisualScript.cpp +++ b/Source/Engine/Content/Assets/VisualScript.cpp @@ -892,6 +892,11 @@ void VisualScriptExecutor::ProcessGroupFunction(Box* boxBase, Node* node, Value& PrintStack(LogType::Error); break; } + if (boxBase->ID == 1) + { + value = instance; + break; + } // TODO: check if instance is of event type (including inheritance) // Add Visual Script method to the event bindings table