Legacy Documentation: Version 5.2
LanguageEnglish
  • C#
  • JS

Script language

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

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

Sumbission failed

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

Close

Cancel

Switch to Manual
public var eventAlphaThreshold: float;
public float eventAlphaThreshold;

Description

The alpha threshold specifying the minimum alpha a pixel must have for the event to be passed through.

The alpha is decided from the image sprite only, while the alpha of the Image Graphic.color is disregarded.

The alphaEventThreshold of 1 is default, which means events inside the rectangle are always passed through, regardless of alpha. In order for lower values to work, the sprite used by the Image must have readable pixels. This can be achived 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; } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961