You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently I use my own custom error messages to print the full path of a node causing an issue:
## Assert that member is set on context
static func assert_member_is_set(context: Node, member: Object, member_name: String):
assert(member, "%s: member '%s' is not set" % [context.get_path(), member_name])
# usage
func _ready():
DebugUtils.assert_member_is_set(self, required_member, "required_member")
self is converted to a string, the full path to that node.
However, I still need to unfold the Remote tree to that node.
Note: It's a bit easier if node was already present in the scene as my local tree stays unfolded, but for nodes instantiated at runtime, I must use the Remote tree, which starts folded, so it's very long to unfold to find the corresponding node, until automatic unfolding on search (#695) is implemented. Recently it seems things are a bit easier as once you unfolded the Remote tree once, it stays unfolded on next run, but that doesn't apply if parent nodes are also instantiated at runtime (they will start folded).
Proposal ideas
a. Add a function push_error_with_context(context: Node, varargs) which adds an extra context parameter, a node that would be revealed and highlighted when user clicks on the error message.
Same for push_warning and assert, adding push_warning_with_context(context: Node, varargs) and assert_with_context(condition: bool, context: Node, message: String = "").
This is inspired by Unity's Debug.Log overloads that take a context Object (click to highlight corresponding GameObject in the scene tree or Asset in the file system).
Variant: I wanted to reuse the existing push_error and push_warning but the fact they use varargs makes it difficult to insert an argument due to the ambiguity (is it a Node used for context, or a Node whose path should be used as string?). For assert though, there is no varargs, so we could more easily reuse the existing assert and add an optional context argument with default value null at the end: assert(condition: bool, message: String = "", context: Node). I suggested assert_with_context though to be consistent with the rest.
b. To avoid changing push_ and assert methods, we could also implement the change at editor level only: the editor would detect node paths inside error messages (strings in the format "/root/path/to/node" with a valid target) and make them clickable to reveal the corresponding node in the Remote tree. One advantage is that this could work everywhere: Stack Trace error message, Output (including normal printed messages), Errors panel
For both a. and b. we must decide whether to reveal the node in the Local tree or the Remote tree.
Scene tree is better to fix actual issues such as bad parameters and unassigned members, but only works on nodes present in the original scene (so we'd have to reveal only runtime nodes in the Remote tree which may look inconsistent).
Remote tree is better to check runtime values and work on nodes instantiated at runtime, but user cannot edit them.
(Unity doesn't have this issue because it doesn't distinguish Local and Remote tree when debugging)
Ideally a button would allow to warp between Scene and Remote tree, so it doesn't matter too much (which would require another proposal).
Bonus: It would be even cooler if we also supported assets in the FileSystem, like Unity. In this case, we should use type Object instead of Node, which is also a base class for Resource. Method b. would have to parse a path to resource in the format "res://...".
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Issue
Currently I use my own custom error messages to print the full path of a node causing an issue:
self
is converted to a string, the full path to that node.However, I still need to unfold the Remote tree to that node.
Note: It's a bit easier if node was already present in the scene as my local tree stays unfolded, but for nodes instantiated at runtime, I must use the Remote tree, which starts folded, so it's very long to unfold to find the corresponding node, until automatic unfolding on search (#695) is implemented. Recently it seems things are a bit easier as once you unfolded the Remote tree once, it stays unfolded on next run, but that doesn't apply if parent nodes are also instantiated at runtime (they will start folded).
Proposal ideas
a. Add a function
push_error_with_context(context: Node, varargs)
which adds an extra context parameter, a node that would be revealed and highlighted when user clicks on the error message.Same for
push_warning
andassert
, addingpush_warning_with_context(context: Node, varargs)
andassert_with_context(condition: bool, context: Node, message: String = "")
.This is inspired by Unity's Debug.Log overloads that take a context Object (click to highlight corresponding GameObject in the scene tree or Asset in the file system).
Variant: I wanted to reuse the existing
push_error
andpush_warning
but the fact they use varargs makes it difficult to insert an argument due to the ambiguity (is it a Node used for context, or a Node whose path should be used as string?). Forassert
though, there is no varargs, so we could more easily reuse the existingassert
and add an optional context argument with default value null at the end:assert(condition: bool, message: String = "", context: Node)
. I suggestedassert_with_context
though to be consistent with the rest.b. To avoid changing
push_
andassert
methods, we could also implement the change at editor level only: the editor would detect node paths inside error messages (strings in the format "/root/path/to/node" with a valid target) and make them clickable to reveal the corresponding node in the Remote tree. One advantage is that this could work everywhere: Stack Trace error message, Output (including normalprint
ed messages), Errors panelFor both a. and b. we must decide whether to reveal the node in the Local tree or the Remote tree.
(Unity doesn't have this issue because it doesn't distinguish Local and Remote tree when debugging)
Ideally a button would allow to warp between Scene and Remote tree, so it doesn't matter too much (which would require another proposal).
Bonus: It would be even cooler if we also supported assets in the FileSystem, like Unity. In this case, we should use type Object instead of Node, which is also a base class for Resource. Method b. would have to parse a path to resource in the format "res://...".
Beta Was this translation helpful? Give feedback.
All reactions