浏览代码

Fix StyleBoxLine's incorrect style margin values

Michael Alexsander 4 年之前
父节点
当前提交
ddf05a7c3c
共有 1 个文件被更改,包括 11 次插入2 次删除
  1. 11 2
      scene/resources/style_box.cpp

+ 11 - 2
scene/resources/style_box.cpp

@@ -937,8 +937,17 @@ void StyleBoxLine::_bind_methods() {
 }
 
 float StyleBoxLine::get_style_margin(Side p_side) const {
-	ERR_FAIL_INDEX_V((int)p_side, 4, thickness);
-	return thickness;
+	ERR_FAIL_INDEX_V((int)p_side, 4, 0);
+
+	if (vertical) {
+		if (p_side == SIDE_LEFT || p_side == SIDE_RIGHT) {
+			return thickness / 2.0;
+		}
+	} else if (p_side == SIDE_TOP || p_side == SIDE_BOTTOM) {
+		return thickness / 2.0;
+	}
+
+	return 0;
 }
 
 Size2 StyleBoxLine::get_center_size() const {