|
1 | 1 | using System.Linq; |
2 | 2 | using System.Text; |
| 3 | +using System.Text.RegularExpressions; // added for placeholder parsing |
3 | 4 | using UnityEngine; |
4 | 5 | using UnityGLTF.Interactivity.Schema; |
5 | 6 |
|
@@ -58,6 +59,44 @@ void NodeAppendLine(GltfInteractivityNode node, string message) |
58 | 59 | } |
59 | 60 | } |
60 | 61 |
|
| 62 | + if (node.Schema.Op == "debug/log") |
| 63 | + { |
| 64 | + if (node.Configuration.ContainsKey(Debug_LogNode.IdConfigMessage)) |
| 65 | + { |
| 66 | + if (node.Configuration[Debug_LogNode.IdConfigMessage].Value == null) |
| 67 | + NodeAppendLine(node, $"Debug Log Node has no Message"); |
| 68 | + else |
| 69 | + { |
| 70 | + var templateStr = node.Configuration[Debug_LogNode.IdConfigMessage].Value; |
| 71 | + // Extract placeholders in the form {placeholder} from the template string and validate they exist as value socket keys |
| 72 | + if (templateStr is string template) |
| 73 | + { |
| 74 | + var matches = Regex.Matches(template, @"\{([^{}]+)\}"); |
| 75 | + foreach (Match m in matches) |
| 76 | + { |
| 77 | + var placeholder = m.Groups[1].Value.Trim(); |
| 78 | + if (string.IsNullOrEmpty(placeholder)) |
| 79 | + continue; // ignore empty braces |
| 80 | + if (!node.ValueInConnection.ContainsKey(placeholder)) |
| 81 | + { |
| 82 | + NodeAppendLine(node, $"Debug Log template placeholder '{{{placeholder}}}' has no matching ValueIn socket"); |
| 83 | + } |
| 84 | + else |
| 85 | + { |
| 86 | + var socket = node.ValueInConnection[placeholder]; |
| 87 | + if (socket.Node == null && socket.Value == null) |
| 88 | + NodeAppendLine(node, $"Debug Log template placeholder '{{{placeholder}}}' socket has neither connection nor default value"); |
| 89 | + } |
| 90 | + } |
| 91 | + } |
| 92 | + else |
| 93 | + { |
| 94 | + NodeAppendLine(node, $"Debug Log Node Message config is not a string (Type={templateStr.GetType().Name})"); |
| 95 | + } |
| 96 | + } |
| 97 | + } |
| 98 | + } |
| 99 | + |
61 | 100 | if (node.Schema.Op == "pointer/set" || node.Schema.Op == "pointer/get") |
62 | 101 | { |
63 | 102 | if (node.ValueInConnection.TryGetValue(PointersHelper.IdPointerNodeIndex, out var valueSocket)) |
|
0 commit comments