Skip to content

Commit a242aef

Browse files
committed
Fix for debug log node getting eaten by the gitignore due to being in a folder named Debug.
1 parent 277948b commit a242aef

File tree

4 files changed

+71
-2
lines changed

4 files changed

+71
-2
lines changed

Runtime/Scripts/Interactivity/Playback/Data/Helpers/Constants.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public static class ConstStrings
3838
public const string TIME_SINCE_LAST_TICK = "timeSinceLastTick";
3939
public const string EXPECTED = "expected";
4040
public const string ACTUAL = "actual";
41-
41+
public const string SEVERITY = "severity";
4242
public const string MESSAGE = "message";
4343
public const string NODE_INDEX = "nodeIndex";
4444
public const string DEFAULT = "default";

Runtime/Scripts/Interactivity/Playback/Nodes/Debug.meta renamed to Runtime/Scripts/Interactivity/Playback/Nodes/Debugging.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
using System.Text.RegularExpressions;
2+
using UnityEngine;
3+
4+
namespace UnityGLTF.Interactivity.Playback
5+
{
6+
public class DebugLog : BehaviourEngineNode
7+
{
8+
private readonly int _severity;
9+
private readonly string _message;
10+
private static readonly Regex _variableRegex = new("{(.*?)}");
11+
12+
public DebugLog(BehaviourEngine engine, Node node) : base(engine, node)
13+
{
14+
if (!TryGetConfig(ConstStrings.MESSAGE, out _message))
15+
_message = "";
16+
17+
if (!TryGetConfig(ConstStrings.SEVERITY, out _severity))
18+
_severity = 0;
19+
}
20+
21+
protected override void Execute(string socket, ValidationResult validationResult)
22+
{
23+
var formatted = FormatString(_message);
24+
25+
switch (_severity)
26+
{
27+
case 0:
28+
Debug.LogWarning(formatted);
29+
break;
30+
31+
case 1:
32+
Debug.LogError(formatted);
33+
break;
34+
35+
default:
36+
Debug.Log(formatted);
37+
break;
38+
}
39+
40+
TryExecuteFlow(ConstStrings.OUT);
41+
}
42+
43+
private string FormatString(string str)
44+
{
45+
var matches = _variableRegex.Matches(str);
46+
47+
foreach (Match match in matches)
48+
{
49+
if (!TryEvaluateValue(match.Groups[1].Value, out IProperty value))
50+
continue;
51+
52+
str = str.Replace(match.Value, value.ToString());
53+
}
54+
55+
return str;
56+
}
57+
}
58+
}

Runtime/Scripts/Interactivity/Playback/Nodes/Debugging/Log.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)