alphaHitTestMinimumThreshold 를 사용해서 raycast가 가능한 alpha값을 조절하는 것
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.alphaHitTestMinimumThreshold = 0.5f;
}
}
1로 설정하게 될 경우, 완전 불투명한 pixel만 선택 가능하게 된다.
완전 꿀팁인듯!
참고
https://sensol2.tistory.com/35
[Unity] 버튼 영역 모양 바꾸기 (세모, 사다리꼴, 그 어떤 모양도 가능)
유니티를 사용하다보면 모양이 있는 버튼을 만들어야 할 때가 생긴다. 위 사진의 경우 직사각형 모양으로 된 버튼들이 서로 겹쳐있어서 클릭이 되지 않는 경우가 발생한다. 버튼을 이미지 영역
sensol2.tistory.com
Unity - Scripting API: UI.Image.alphaHitTestMinimumThreshold
Alpha values less than the threshold will cause raycast events to pass through the Image. An 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
docs.unity3d.com
'Unity > 잡학 사전' 카테고리의 다른 글
[Unity] animator (0) | 2022.10.21 |
---|---|
[Unity] Particle System (0) | 2022.10.20 |
[Unity] Sprite Renderer (0) | 2022.09.27 |
[Unity] 파티클 시스템 이미지 뒤로 보내는 방법(Particle system behind the image) (0) | 2022.09.26 |
[Unity/Animation] 유니티 애니메이션 단위 (0) | 2022.09.16 |