diff --git a/game/addons/world_generator/ui/RectEditor.gd b/game/addons/world_generator/ui/RectEditor.gd index 302eeac2..2eb11664 100644 --- a/game/addons/world_generator/ui/RectEditor.gd +++ b/game/addons/world_generator/ui/RectEditor.gd @@ -3,23 +3,25 @@ extends PanelContainer var last_edited_res : WorldGenBaseResource = null -func _init(): -# Control/EditorZoomWidget - pass - func set_plugin(plugin : EditorPlugin) -> void: - $ScrollContainer/MarginContainer/RectView.set_plugin(plugin) + get_node("ScrollContainer/MarginContainer/RectView").set_plugin(plugin) func set_edited_resource(res : WorldGenBaseResource): + get_node("ScrollContainer/MarginContainer/RectView").set_edited_resource(res) + if res && res != last_edited_res: var r : Rect2 = res.get_rect() + last_edited_res = res if r.size.x > 0: - var rsx : float = $ScrollContainer/MarginContainer.rect_size.x - var scale : float = rsx / r.size.x + var rsx : float = get_node("ScrollContainer").rect_size.x + var scale : float = rsx / r.size.x * 0.8 - $Control/EditorZoomWidget.zoom = scale - - + get_node("Control/EditorZoomWidget").zoom = scale + get_node("ScrollContainer/MarginContainer/RectView").apply_zoom() - $ScrollContainer/MarginContainer/RectView.set_edited_resource(res) + var sb : ScrollBar = get_node("ScrollContainer").get_h_scrollbar() + sb.ratio = 1 + + sb = get_node("ScrollContainer").get_v_scrollbar() + sb.ratio = 1