Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Button Hidden Resolve

The button with the image is not pressed.
The buttons in front of you are pressed even though you pressed the button in the back because the two buttons with the images are overlapped.
I think the image range covers the button behind you, so how can I solve this phenomenon?

I don’t know how to solve it.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Here is your solution:

Use alphaHitTestMinimumThreshold!
image settings
First of all, since we’re going to touch the image settings in the code, we’ll set Read/Write Enabled in Advanced to true for the image. Then, write the code below and put it in the button.

using UnityEngine;
using UnityEngine.UI;

[RequireComponent(typeof(Image))]
public class CustomButton : MonoBehaviour
{
    private void Start()
    {
        GetComponent<Image>().alphaHitTestMinimumThreshold = 0.1f;
    }

}

Then you can solve this problem with just one line of code.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading