- Home /
This question was
closed Dec 07, 2017 at 06:25 PM by
Moises_Pelaez for the following reason:
The question is answered, right answer was accepted
Question by
Moises_Pelaez · Dec 07, 2017 at 04:05 PM ·
unity 5uiimagetoggletoggle button
How to make an UI element clickable based on its fill amount?
I have a problem and have followed this answer. I'm trying to make a UI Toggle to be clickeable only in the visible area it has ignoring the transparency. What I try to do is to set the 'Image Type' to 'Filled' and reduce its 'Fill Amount' in the 'Image' component.
The following code from the answer worked for me but having the 'Image Type' on 'Simple':
using UnityEngine;
using System.Collections;
using UnityEngine.UI; // Required when Using UI elements.
public class AlphaButton : MonoBehaviour
{
public float AlphaThreshold = 0.1f;
void Start()
{
this.GetComponent<Image>().alphaHitTestMinimumThreshold = AlphaThreshold;
}
}
But when I change to 'Filled' what I see is it just ignores the alpha from the original image but not the transparency added when I reduce the 'Fill Amount'. How can I solve this?
Comment