#What is this weird editor tool bug?

1 messages · Page 1 of 1 (latest)

gilded steppe
#

I need help identifying it, I don't know how to debug tool scripts...

So, I made a tool script to position 2 Texture rects at the edges of the screen.
I wanted to preview the script in the editor so I made it a tool.

It works most of the time, but SOMETIMES I saw the textrects draw over the Engine UI itself instead of the editor viewport (picture attached). In these cases I had to restart Godot because mouse input was blocked (despite the textures mouse input being set to ignore)

Here is the only part of the code that runs in the Editor:

    # Get the screen size
    var screen_size := get_viewport().get_visible_rect().size if not Engine.is_editor_hint() else Vector2(
        ProjectSettings.get_setting("display/window/size/viewport_width"),
        ProjectSettings.get_setting("display/window/size/viewport_height")
    )

    # Set the lid sizes
    var lid_height := top_lid.size.y
    top_lid.size.x = screen_size.x
    bottom_lid.size = top_lid.size

    # Get the screen corners
    var screen_top_left := Vector2(0, 0)
    var screen_bottom_left := Vector2(0, screen_size.y)
    
    # Get the initial lid positions
    initial_top_left_position = screen_top_left - Vector2(0, lid_height)
    initial_bottom_left_position = screen_bottom_left
    top_lid.position = initial_top_left_position
    bottom_lid.position = initial_bottom_left_position

    # Get the target lid positions
    top_lid_target_position = screen_bottom_left - Vector2(0, lid_height)
    bottom_lid_target_position = screen_top_left

    # Set the lid margins
    var top_lid_margin := top_lid.get_child(0) as ColorRect
    var bottom_lid_margin := bottom_lid.get_child(0) as ColorRect

    top_lid_margin.size.x = screen_size.x
    bottom_lid_margin.size.x = screen_size.x

    top_lid_margin.size.y = 2000
    bottom_lid_margin.size.y = 2000

    top_lid_margin.position = Vector2(0, -top_lid_margin.size.y)
    bottom_lid_margin.position = Vector2(0, bottom_lid.size.y)```
#

You can see the textures being drawn over the editor at the bottom of the first image