AirtestProject / AirtestProject/Poco
Unity3D的UGUI,当pivot不是(0.5,0.5)时,使用focus不是预期的结果
- Lingua principale
- Python
- Stelle
- 2k
- Fork
- 341
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
**相关截图**


**描述问题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),感觉这样的结果才是正确的,望解答下疑问

**相关代码**
例如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
```
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Valutazione
Questa issue non è ancora stata valutata.