AirtestProject / AirtestProject/Poco

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

Offen
#164 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Python
Sterne
2k
Forks
341
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

**相关截图**
![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
```

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.