diff --git a/Source/Editor/Options/OptionsModule.cs b/Source/Editor/Options/OptionsModule.cs
index 49e30a53d..70600d026 100644
--- a/Source/Editor/Options/OptionsModule.cs
+++ b/Source/Editor/Options/OptionsModule.cs
@@ -299,6 +299,7 @@ namespace FlaxEditor.Options
TextBoxBackgroundSelected = Color.FromBgra(0xFF3F3F46),
CollectionBackgroundColor = Color.FromBgra(0x14CCCCCC),
ProgressNormal = Color.FromBgra(0xFF0ad328),
+ ProgressError = new Color(0.79f, 0.146f, 0.0f, 1.0f),
Selection = Color.Orange * 0.4f,
SelectionBorder = Color.Orange,
@@ -362,6 +363,7 @@ namespace FlaxEditor.Options
TextBoxBackgroundSelected = new Color(0.73f, 0.73f, 0.80f, 1f),
CollectionBackgroundColor = new Color(0.85f, 0.85f, 0.88f, 1f),
ProgressNormal = new Color(0.03f, 0.65f, 0.12f, 1f),
+ ProgressError = new Color(0.79f, 0.146f, 0.0f, 1.0f),
Selection = Color.Orange * 0.4f,
SelectionBorder = Color.Orange,
diff --git a/Source/Editor/Surface/Archetypes/BehaviorTree.cs b/Source/Editor/Surface/Archetypes/BehaviorTree.cs
index c6fc4c35d..2ecb0f20c 100644
--- a/Source/Editor/Surface/Archetypes/BehaviorTree.cs
+++ b/Source/Editor/Surface/Archetypes/BehaviorTree.cs
@@ -30,6 +30,7 @@ namespace FlaxEditor.Surface.Archetypes
protected const float DecoratorsMarginY = 2.0f;
protected bool _debugRelevant;
+ protected int _debugDecoratorResult = -1;
protected string _debugInfo;
protected Float2 _debugInfoSize;
protected ScriptType _type;
@@ -90,6 +91,7 @@ namespace FlaxEditor.Surface.Archetypes
protected virtual void UpdateDebugInfo(BehaviorTreeNode instance = null, Behavior behavior = null)
{
_debugRelevant = false;
+ _debugDecoratorResult = -1;
_debugInfo = null;
_debugInfoSize = Float2.Zero;
if (!instance)
@@ -98,6 +100,8 @@ namespace FlaxEditor.Surface.Archetypes
{
// Get debug description for the node based on the current settings
_debugRelevant = Behavior.GetNodeDebugRelevancy(instance, behavior);
+ if (instance is BehaviorTreeDecorator decorator && behavior && behavior.IsDuringPlay && behavior.Result == BehaviorUpdateResult.Running)
+ _debugDecoratorResult = Behavior.GetDecoratorDebugResult(decorator, behavior);
_debugInfo = Behavior.GetNodeDebugInfo(instance, behavior);
if (!string.IsNullOrEmpty(_debugInfo))
_debugInfoSize = Style.Current.FontSmall.MeasureText(_debugInfo);
@@ -808,7 +812,12 @@ namespace FlaxEditor.Surface.Archetypes
// Debug Info
if (!string.IsNullOrEmpty(_debugInfo))
{
- Render2D.DrawText(style.FontSmall, _debugInfo, new Rectangle(4, _headerRect.Bottom, _debugInfoSize), style.Foreground, TextAlignment.Near, TextAlignment.Center, TextWrapping.NoWrap, 1, 0.8f);
+ var color = style.Foreground;
+ if (_debugDecoratorResult == 0)
+ color = style.ProgressError;
+ else if (_debugDecoratorResult == 1)
+ color = style.ProgressNormal;
+ Render2D.DrawText(style.FontSmall, _debugInfo, new Rectangle(4, _headerRect.Bottom, _debugInfoSize), color, TextAlignment.Near, TextAlignment.Center, TextWrapping.NoWrap, 1, 0.8f);
}
// Outline
diff --git a/Source/Engine/AI/Behavior.cpp b/Source/Engine/AI/Behavior.cpp
index 55d96e415..4a38efb60 100644
--- a/Source/Engine/AI/Behavior.cpp
+++ b/Source/Engine/AI/Behavior.cpp
@@ -209,7 +209,25 @@ String Behavior::GetNodeDebugInfo(const BehaviorTreeNode* node, Behavior* behavi
if (!node)
return String::Empty;
BehaviorUpdateContext context;
+ InitNodeDebugContext(node, behavior, context);
+ return node->GetDebugInfo(context);
+}
+
+int32 Behavior::GetDecoratorDebugResult(BehaviorTreeDecorator* node, Behavior* behavior)
+{
+ if (!node)
+ return -1;
+ BehaviorUpdateContext context;
+ InitNodeDebugContext(node, behavior, context);
+ return node->CanUpdate(context) ? 1 : 0;
+}
+
+void Behavior::InitNodeDebugContext(const BehaviorTreeNode* node, Behavior* behavior, BehaviorUpdateContext& context)
+{
+ // Zero out context
Platform::MemoryClear(&context, sizeof(context));
+
+ // Check if the node is relevant (active in tree with state created)
if (GetNodeDebugRelevancy(node, behavior))
{
// Pass behavior and knowledge data only for relevant nodes to properly access it
@@ -219,7 +237,6 @@ String Behavior::GetNodeDebugInfo(const BehaviorTreeNode* node, Behavior* behavi
context.RelevantNodes = &behavior->_knowledge.RelevantNodes;
context.Time = behavior->_totalTime;
}
- return node->GetDebugInfo(context);
}
#endif
diff --git a/Source/Engine/AI/Behavior.h b/Source/Engine/AI/Behavior.h
index cdad7331b..c99abe192 100644
--- a/Source/Engine/AI/Behavior.h
+++ b/Source/Engine/AI/Behavior.h
@@ -110,5 +110,7 @@ private:
// Editor-only utilities to debug nodes state.
API_FUNCTION(Internal) static bool GetNodeDebugRelevancy(const BehaviorTreeNode* node, const Behavior* behavior);
API_FUNCTION(Internal) static String GetNodeDebugInfo(const BehaviorTreeNode* node, Behavior* behavior);
+ API_FUNCTION(Internal) static int32 GetDecoratorDebugResult(class BehaviorTreeDecorator* node, Behavior* behavior);
+ static void InitNodeDebugContext(const BehaviorTreeNode* node, Behavior* behavior, BehaviorUpdateContext& context);
#endif
};
diff --git a/Source/Engine/Scripting/Scripting.cs b/Source/Engine/Scripting/Scripting.cs
index 229e411f3..7d3aba4cf 100644
--- a/Source/Engine/Scripting/Scripting.cs
+++ b/Source/Engine/Scripting/Scripting.cs
@@ -300,6 +300,7 @@ namespace FlaxEngine
TextBoxBackgroundSelected = Color.FromBgra(0xFF3F3F46),
CollectionBackgroundColor = Color.FromBgra(0x14CCCCCC),
ProgressNormal = Color.FromBgra(0xFF0ad328),
+ ProgressError = new Color(0.79f, 0.146f, 0.0f, 1.0f),
Statusbar = new Style.StatusbarStyle
{
PlayMode = Color.FromBgra(0xFF2F9135),
diff --git a/Source/Engine/UI/GUI/Style.cs b/Source/Engine/UI/GUI/Style.cs
index 5424d9f29..ae9691bdd 100644
--- a/Source/Engine/UI/GUI/Style.cs
+++ b/Source/Engine/UI/GUI/Style.cs
@@ -170,6 +170,12 @@ namespace FlaxEngine.GUI
[EditorOrder(200)]
public Color ProgressNormal;
+ ///
+ /// The progress error color.
+ ///
+ [EditorOrder(201)]
+ public Color ProgressError;
+
///
/// The selection and drag drop highlights colors.
///