From 69054c8fa5e1e62be966f2e4555f260446db0413 Mon Sep 17 00:00:00 2001 From: Relintai Date: Fri, 5 Aug 2022 21:23:05 +0200 Subject: [PATCH] Also handle if the y axis is bigger in the rect editor. --- game/addons/world_generator/ui/RectEditor.gd | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/game/addons/world_generator/ui/RectEditor.gd b/game/addons/world_generator/ui/RectEditor.gd index 4d6b71d9..83c26058 100644 --- a/game/addons/world_generator/ui/RectEditor.gd +++ b/game/addons/world_generator/ui/RectEditor.gd @@ -13,9 +13,16 @@ func set_edited_resource(res : WorldGenBaseResource): var r : Rect2 = res.get_rect() last_edited_res = res - if r.size.x > 0: - var rsx : float = get_node("ScrollContainer").rect_size.x - var scale : float = rsx / r.size.x * 0.5 + var axis : int = 0 + + if r.size.x > r.size.y: + axis = Vector2.AXIS_X + else: + axis = Vector2.AXIS_Y + + if r.size[axis] > 0: + var rsx : float = get_node("ScrollContainer").rect_size[axis] + var scale : float = rsx / r.size[axis] * 0.5 get_node("Control/EditorZoomWidget").zoom = scale get_node("ScrollContainer/MarginContainer/RectView").apply_zoom()