简体   繁体   English

如何使用 c# 在 unity 2d Android 中禁用屏幕特定部分的触摸?

[英]How to disable touch on specific part of the screen in unity 2d Android using c#?

I have a drawing manager which draws lines using line renderer, what I want is that when I click on a specific area in my game, the screen should not take any input or line renderer shouldn't draw anything on that specific area.我有一个使用线条渲染器绘制线条的绘图管理器,我想要的是当我单击游戏中的特定区域时,屏幕不应该接受任何输入,或者线条渲染器不应该在该特定区域上绘制任何东西。

Basically I am using a button on which I don't want any input for my line renderer.基本上,我使用的是一个按钮,我不想在该按钮上为我的线条渲染器输入任何内容。 I want it (Button) to perform its own functions but when I click on the button the line renderer shouldn't work or it shouldn't draw any lines.我希望它(按钮)执行自己的功能,但是当我单击按钮时,线条渲染器不应该工作或者它不应该绘制任何线条。

I couldn't find anything related to this on the inte.net.我在 inte.net 上找不到与此相关的任何内容。

Thanks in Advance!提前致谢!

Maybe you can add simply UI Panel object with raycast target = enabled .也许您可以简单地添加带有 raycast target = enabledUI 面板 object Like this way you can block player's touch.像这样你可以阻止玩家的触摸。

I figured it out, basically I just used the list to check if a line has been drawn or not.我想通了,基本上我只是用列表来检查是否画了一条线。 The line object is stored inside the list.行 object 存储在列表中。 If the line exists inside the list the button will give response and will be interactable but if it doesn't contain any item, it will turn off the script which helps generating the lines.如果行存在于列表中,按钮将给出响应并且可以交互,但如果它不包含任何项目,它将关闭有助于生成行的脚本。

Here is the code:这是代码:

  if (DrawingManager.Instance.paths.Contains(DrawingManager.Instance.clone))
    {
        VehicleSimpleControl._instance.RacePress = true;
        //VehicleSimpleControl.Instance.aceleration = 3.2f;
        resetButton.SetActive(false);
        Debug.Log("racepress true");
    }
    else
    {
        drawingManager.enabled = false;
    }

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

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