fix WorldCanvas scale animation

This commit is contained in:
Nordup 2024-03-24 20:51:50 +04:00
parent 3a77eb7a3d
commit 8c726d4033
2 changed files with 4 additions and 6 deletions

View file

@ -300,12 +300,11 @@ grow_horizontal = 2
grow_vertical = 2
theme_override_constants/separation = 0
[node name="WorldCanvas" type="Control" parent="HBoxContainer" node_paths=PackedStringArray("render_result")]
[node name="WorldCanvas" type="Control" parent="HBoxContainer"]
custom_minimum_size = Vector2(1300, 0)
layout_mode = 2
size_flags_horizontal = 0
script = ExtResource("9_ncfxj")
render_result = NodePath("RenderResult")
[node name="RenderResult" type="TextureRect" parent="HBoxContainer/WorldCanvas"]
layout_mode = 1

View file

@ -1,20 +1,19 @@
extends Control
@export var render_result: RenderResult
@export var interpolate: float:
set(value):
interpolate = value
animate(value)
var initial: int = 1300
var full_screen: int = 1920
var initial: int
var full_screen: int
func _ready() -> void:
var viewport_width = ProjectSettings.get_setting("display/window/size/viewport_width", 1152)
var scale_width = float(custom_minimum_size.x) / viewport_width
full_screen = render_result.width
full_screen = int(get_parent_control().size.x)
initial = int(full_screen * scale_width)
custom_minimum_size.x = initial
Debug.logclr("WorldCanvas initial: %d full_screen: %d" % [initial, full_screen], Color.DIM_GRAY)