Skip to content

Commit 1fe0892

Browse files
committed
BlockCanvas: Use block models when loading
And fallback to the previous behavior if the block isn't ported to the catalog yet. https://phabricator.endlessm.com/T35536
1 parent 75c264e commit 1fe0892

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

addons/block_code/ui/block_canvas/block_canvas.gd

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,16 @@ func clear_canvas():
160160

161161

162162
func load_tree(parent: Node, node: SerializedBlockTreeNode):
163-
var _block_scene_path = _block_scenes_by_class[node.serialized_block.block_class]
164-
var scene: Block = load(_block_scene_path).instantiate()
163+
var scene: Block = Util.instantiate_block(node.name)
164+
165+
# TODO: Remove once the data/UI decouple is done.
166+
if scene == null:
167+
var _block_scene_path = _block_scenes_by_class[node.serialized_block.block_class]
168+
scene = load(_block_scene_path).instantiate()
165169
for prop_pair in node.serialized_block.serialized_props:
166170
scene.set(prop_pair[0], prop_pair[1])
171+
172+
scene.position = node.position
167173
parent.add_child(scene)
168174

169175
var scene_block: Block = scene as Block

0 commit comments

Comments
 (0)