We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem: There isn't a simple way to get current CanvasEditor/SpatialEditor viewports and SpatialEditor's camera in a tool script (not a plugin).
CanvasEditor
SpatialEditor
SpatialEditor's
Solution: This is a workaround:
func _ready(): var editor_viewport_2d = find_viewport_2d(get_node("/root/EditorNode"), 0) var editor_viewport_3d = find_viewport_3d(get_node("/root/EditorNode"), 0) var editor_camera_3d = editor_viewport_3d.get_child(0) func find_viewport_2d(node: Node, recursive_level): if node.get_class() == "CanvasItemEditor": return node.get_child(1).get_child(0).get_child(0).get_child(0).get_child(0) else: recursive_level += 1 if recursive_level > 15: return null for child in node.get_children(): var result = find_viewport_2d(child, recursive_level) if result != null: return result func find_viewport_3d(node: Node, recursive_level): if node.get_class() == "SpatialEditor": return node.get_child(1).get_child(0).get_child(0).get_child(0).get_child(0).get_child(0) else: recursive_level += 1 if recursive_level > 15: return null for child in node.get_children(): var result = find_viewport_3d(child, recursive_level) if result != null: return result
Additional context: the code copied from: godotengine/godot-proposals#1302 (comment)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Problem:
There isn't a simple way to get current
CanvasEditor
/SpatialEditor
viewports andSpatialEditor's
camera in a tool script (not a plugin).Solution:
This is a workaround:
Additional context:
the code copied from:
godotengine/godot-proposals#1302 (comment)
The text was updated successfully, but these errors were encountered: