Add outline for relevant BT nodes when debugging tree
This commit is contained in:
@@ -29,6 +29,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
protected const float DecoratorsMarginX = 5.0f;
|
||||
protected const float DecoratorsMarginY = 2.0f;
|
||||
|
||||
protected bool _debugRelevant;
|
||||
protected string _debugInfo;
|
||||
protected Float2 _debugInfoSize;
|
||||
protected ScriptType _type;
|
||||
@@ -88,6 +89,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
|
||||
protected virtual void UpdateDebugInfo(BehaviorTreeNode instance = null, Behavior behavior = null)
|
||||
{
|
||||
_debugRelevant = false;
|
||||
_debugInfo = null;
|
||||
_debugInfoSize = Float2.Zero;
|
||||
if (!instance)
|
||||
@@ -95,6 +97,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
if (instance)
|
||||
{
|
||||
// Get debug description for the node based on the current settings
|
||||
_debugRelevant = Behavior.GetNodeDebugRelevancy(instance, behavior);
|
||||
_debugInfo = Behavior.GetNodeDebugInfo(instance, behavior);
|
||||
if (!string.IsNullOrEmpty(_debugInfo))
|
||||
_debugInfoSize = Style.Current.FontSmall.MeasureText(_debugInfo);
|
||||
@@ -183,6 +186,15 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
var style = Style.Current;
|
||||
Render2D.DrawText(style.FontSmall, _debugInfo, new Rectangle(4, _headerRect.Bottom + 4, _debugInfoSize), style.Foreground);
|
||||
}
|
||||
|
||||
// Debug relevancy outline
|
||||
if (_debugRelevant)
|
||||
{
|
||||
var colorTop = Color.LightYellow;
|
||||
var colorBottom = Color.Yellow;
|
||||
var backgroundRect = new Rectangle(Float2.One, Size - new Float2(2.0f));
|
||||
Render2D.DrawRectangle(backgroundRect, colorTop, colorTop, colorBottom, colorBottom);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnDestroy()
|
||||
@@ -685,6 +697,7 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
// Add drag button to reorder decorator
|
||||
_dragIcon = new DragImage
|
||||
{
|
||||
AnchorPreset = AnchorPresets.TopRight,
|
||||
Color = Style.Current.ForegroundGrey,
|
||||
Parent = this,
|
||||
Margin = new Margin(1),
|
||||
|
||||
@@ -169,7 +169,12 @@ void Behavior::OnDisable()
|
||||
|
||||
#if USE_EDITOR
|
||||
|
||||
String Behavior::GetNodeDebugInfo(BehaviorTreeNode* node, Behavior* behavior)
|
||||
bool Behavior::GetNodeDebugRelevancy(const BehaviorTreeNode* node, const Behavior* behavior)
|
||||
{
|
||||
return node && behavior && behavior->_knowledge.RelevantNodes.Get(node->_executionIndex);
|
||||
}
|
||||
|
||||
String Behavior::GetNodeDebugInfo(const BehaviorTreeNode* node, Behavior* behavior)
|
||||
{
|
||||
if (!node)
|
||||
return String::Empty;
|
||||
|
||||
@@ -93,7 +93,8 @@ public:
|
||||
|
||||
private:
|
||||
#if USE_EDITOR
|
||||
// Editor-only utility to debug nodes state.
|
||||
API_FUNCTION(Internal) static String GetNodeDebugInfo(BehaviorTreeNode* node, Behavior* behavior);
|
||||
// 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);
|
||||
#endif
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user