AirtestProject / AirtestProject/Poco

Unity3D的UGUI,当pivot不是(0.5,0.5)时,使用focus不是预期的结果

Đang mở
#164 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Python
Star
2k
Fork
341
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

**相关截图**
![image](https://user-images.githubusercontent.com/23083411/54699544-2cb32580-4b6c-11e9-9f42-c48e7f7af571.png)

![image](https://user-images.githubusercontent.com/23083411/54699448-fd9cb400-4b6b-11e9-90ed-dc5ad70cd374.png)

**描述问题bug**
比如上面focus=[0,0]和focus=[0.5,0.5],当pivot不是(0.5,0.5)的时候,focus就不是预期想要的左上角focus=[0,0]点和图形中心点focus=[0.5,0.5]了

**预期效果**
下面是把Anchor修改成固定返回(0.5,0.5),感觉这样的结果才是正确的,望解答下疑问

![image](https://user-images.githubusercontent.com/23083411/54699752-97646100-4b6c-11e9-968b-eef3c2e69fb8.png)

**相关代码**
例如get_position里使用focus参数时,anchorPoint属性值会参与计算,当anchor不是0.5,0.5时,结果不符合预期
```
def get_position(self, focus=None):
focus = focus or self._focus or 'anchor'
if focus == 'anchor':
pos = self.attr('pos')
elif focus == 'center':
x, y = self.attr('pos')
w, h = self.get_size()
ap_x, ap_y = self.attr("anchorPoint")
fx, fy = 0.5, 0.5
pos = [x + w * (fx - ap_x), y + h * (fy - ap_y)]
elif type(focus) in (list, tuple):
x, y = self.attr('pos')
w, h = self.get_size()
ap_x, ap_y = self.attr("anchorPoint")
fx, fy = focus
pos = [x + w * (fx - ap_x), y + h * (fy - ap_y)]
else:
raise TypeError('Unsupported focus type {}. '
'Only "anchor/center" or 2-list/2-tuple available.'.format(type(focus)))
return pos
```

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.