Implement zoom for RectView.

This commit is contained in:
Relintai 2021-12-23 18:08:13 +01:00
parent dd7024c0ed
commit 9aa18a9278
2 changed files with 14 additions and 0 deletions

View File

@ -32,6 +32,7 @@ margin_top = 200.0
margin_right = 200.0
margin_bottom = 200.0
script = ExtResource( 3 )
zoom_widget_path = NodePath("../../../Control/EditorZoomWidget")
[node name="Control" type="Control" parent="."]
margin_left = 7.0

View File

@ -3,8 +3,21 @@ extends Control
var rect_editor_node_scene : PackedScene = preload("res://addons/world_generator/ui/RectViewNode.tscn")
export(NodePath) var zoom_widget_path : NodePath = ""
var edited_resource : WorldGenBaseResource = null
func _enter_tree():
var zoom_widget : Node = get_node_or_null(zoom_widget_path)
if !zoom_widget:
return
zoom_widget.connect("zoom_changed", self, "on_zoom_changed")
func on_zoom_changed(zoom : float) -> void:
rect_scale = Vector2(zoom, zoom)
func _draw():
draw_rect(Rect2(Vector2(), get_size()), Color(0.2, 0.2, 0.2, 1))