简体   繁体   中英

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.

Thanks in Advance!

Maybe you can add simply UI Panel object with raycast target = enabled . 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. 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;
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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