From 7b4f044f4336a098d520b8259bd5c6675fa2c988 Mon Sep 17 00:00:00 2001 From: Relintai Date: Sat, 25 Dec 2021 23:34:33 +0100 Subject: [PATCH] Fixed keeping zoom in RectView. --- game/addons/world_generator/ui/RectView.gd | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/game/addons/world_generator/ui/RectView.gd b/game/addons/world_generator/ui/RectView.gd index 890e7e97..bf0cad76 100644 --- a/game/addons/world_generator/ui/RectView.gd +++ b/game/addons/world_generator/ui/RectView.gd @@ -5,6 +5,8 @@ var rect_editor_node_scene : PackedScene = preload("res://addons/world_generator export(NodePath) var zoom_widget_path : NodePath = "" +var stored_rect_scale : Vector2 = Vector2(1, 1) + var edited_resource : WorldGenBaseResource = null func _enter_tree(): @@ -14,9 +16,17 @@ func _enter_tree(): return zoom_widget.connect("zoom_changed", self, "on_zoom_changed") + connect("visibility_changed", self, "on_visibility_changed") + +func on_visibility_changed() -> void: + call_deferred("reapply_zoom") + +func reapply_zoom() -> void: + rect_scale = stored_rect_scale func on_zoom_changed(zoom : float) -> void: - rect_scale = Vector2(zoom, zoom) + stored_rect_scale = Vector2(zoom, zoom) + rect_scale = Vector2(zoom, zoom) func _draw(): draw_rect(Rect2(Vector2(), get_size()), Color(0.2, 0.2, 0.2, 1))