简体   繁体   English

如果未覆盖游戏对象,则 Unity2d 手柄单击

[英]Unity2d Handle Click if GameObject not Covered

I want to allow clicks on a GameObject if that object is not covered.如果 object 未被覆盖,我想允许点击游戏对象。

I have tried:我努力了:

    private void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            RaycastHit2D hit2D = Physics2D.Raycast(Camera.main.transform.position,
                Camera.main.ScreenToWorldPoint(Input.mousePosition));

            if (hit2D.collider)
            {
                 executeLogic();
            }
        }
    }

When covering the screen with an interstitial ad executeLogic() is still being run on click.当使用插页式广告覆盖屏幕时,executeLogic() 仍在点击时运行。 How do I fix this?我该如何解决?

I think you would need to maintain a flag inside AdManager script.我认为您需要在 AdManager 脚本中维护一个标志。 When you Ad is shown you would require it to set to true and inside your logic for update you would have to use that boolean to stop executing logic.当您显示广告时,您需要将其设置为 true,并且在您的更新逻辑中,您必须使用该 boolean 来停止执行逻辑。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM