Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在Unity工程中,poco没办法点击Toggle,以及获取Toggle状态 #78

Open
gameboys84 opened this issue Aug 6, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@gameboys84
Copy link

gameboys84 commented Aug 6, 2020

还在熟悉poco中,不确定这是否为issue,但从实际效果以及LOG中确实没看到对toggle的处理

Payload details:
type : Toggle
name : AgreeToggle
visible : True
pos : [0.417149127, 0.856406331]
size : [0.231052265, 0.0671875]
scale : [1.0, 1.0]
anchorPoint : [0.5, 0.5]
zOrders : {'global': 0.0, 'local': -100.0}
clickable : False
components : ['RectTransform', 'Toggle']
_ilayer : 0
layer : b'Default'
_instanceId : -4854

补充下Unity的版本,2017.4.16, poco使用的Git最新版本

@gameboys84
Copy link
Author

自己找到了一个解决方案:
修改UnityNode.cs中的这个函数

        private bool GameObjectClickable(List<string> components)
        {
            Button button = gameObject.GetComponent<Button>();
            
            if (button != null)
            {
                // button
                return button.isActiveAndEnabled;
            }
            else
            {
                // niqf, maybe is a toggle?
                Toggle toggle = gameObject.GetComponent<Toggle>();
                return toggle ? toggle.isActiveAndEnabled : false;
            }
        }

脚本里就可以正常点击了,不过sdk对toggle区域判断好像有一点问题,可以根据实际情况修改focus的位置

poco("AgreeToggle").focus([0.1,0.5]).click()

poco("AgreeToggle").focus([0.9,0.5]).click()

@yimelia yimelia added the enhancement New feature or request label Aug 6, 2020
@yimelia
Copy link
Member

yimelia commented Aug 7, 2020

非常感谢,我们后续再做一些测试,如果可行的话会加入到代码中

@gameboys84
Copy link
Author

非常感谢,我们后续再做一些测试,如果可行的话会加入到代码中

感谢回复,如果可能的话,还希望能获取toggle当前“是否选中”的状态

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants