浏览代码

GUI: Touch screen button click area now is synced with its draw

Mateo Kuruk Miccino 5 年之前
父节点
当前提交
1cba7fb180
共有 1 个文件被更改,包括 3 次插入2 次删除
  1. 3 2
      scene/2d/touch_screen_button.cpp

+ 3 - 2
scene/2d/touch_screen_button.cpp

@@ -259,9 +259,10 @@ bool TouchScreenButton::_is_point_inside(const Point2 &p_point) {
 	bool check_rect = true;
 
 	if (shape.is_valid()) {
-
 		check_rect = false;
-		Transform2D xform = shape_centered ? Transform2D().translated(shape->get_rect().size * 0.5f) : Transform2D();
+
+		Vector2 size = texture.is_null() ? shape->get_rect().size : texture->get_size();
+		Transform2D xform = shape_centered ? Transform2D().translated(size * 0.5f) : Transform2D();
 		touched = shape->collide(xform, unit_rect, Transform2D(0, coord + Vector2(0.5, 0.5)));
 	}