mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
Allow Node.create_tween() outside SceneTree
This commit is contained in:
parent
fa48a51183
commit
0de8a736da
2 changed files with 11 additions and 4 deletions
|
|
@ -2326,8 +2326,14 @@ void Node::_propagate_replace_owner(Node *p_owner, Node *p_by_owner) {
|
|||
|
||||
Ref<Tween> Node::create_tween() {
|
||||
ERR_THREAD_GUARD_V(Ref<Tween>());
|
||||
ERR_FAIL_NULL_V_MSG(data.tree, nullptr, "Can't create Tween when not inside scene tree.");
|
||||
Ref<Tween> tween = get_tree()->create_tween();
|
||||
|
||||
SceneTree *tree = data.tree;
|
||||
if (!tree) {
|
||||
tree = SceneTree::get_singleton();
|
||||
}
|
||||
ERR_FAIL_NULL_V_MSG(tree, Ref<Tween>(), "No available SceneTree to create the Tween.");
|
||||
|
||||
Ref<Tween> tween = tree->create_tween();
|
||||
tween->bind_node(this);
|
||||
return tween;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue