Version: 2017.3 (switch to 2017.4)
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Method group is Obsolete

Image.eventAlphaThreshold

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Obsolete public var eventAlphaThreshold: float;
Obsolete public float eventAlphaThreshold;

Description

The alpha threshold specifies the minimum alpha a pixel must have for the event to considered a "hit" on the Image.

Obsolete. You should use Image.alphaHitTestMinimumThreshold instead. Alpha values less than the threshold will cause raycast events to pass through the Image. An alpha value of 1 would cause only fully opaque pixels to register raycast events on the Image. The alpha tested is retrieved from the image sprite only, while the alpha of the Image Graphic.color is disregarded.

alphaEventThreshold defaults to 0; all raycast events inside the Image rectangle are considered a hit. In order for greater than 0 to values to work, the sprite used by the Image must have readable pixels. This can be achieved by enabling Read/Write enabled in the advanced Texture Import Settings for the sprite and disabling atlassing for the sprite.

#pragma strict
// Required when Using UI elements.
public var theButton: Image;
// Use this for initialization
function Start() {
	theButton.eventAlphaThreshold = 0.5f;
}
using UnityEngine;
using System.Collections;
using UnityEngine.UI; // Required when Using UI elements.

public class ExampleClass : MonoBehaviour { public Image theButton;

// Use this for initialization void Start() { theButton.eventAlphaThreshold = 0.5f; } }

Did you find this page useful? Please give it a rating: