Hey everyone, I was wondering if anyone could help me with this. I have been trying to figure it out for days. I would really appreciate the help. I am trying to figure out how to null/not have click activated when I click on the pop up UIs. The pictures as shown:
I have a script in which I am able to click on the triangles. The blue space is nulled out/does not do anything. The code I am using is:
public class ClickObject : MonoBehaviour {
[SerializeField]
private GameObject NextLevelUI;
[SerializeField]
private GameObject TryAgainUI;
void Update (){
RaycastHit2D hit;
if(Input.GetMouseButtonDown(0)){
hit=Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition) , Vector2.zero);
if (hit.collider != null){
TryAgainUI.SetActive(true);
if(hit.collider.GetComponent<MoveSample>()!= null && hit.transform.gameObject.tag=="TriangleP"){
NextLevelUI.SetActive(true);
TryAgainUI.SetActive (false);{
Debug.Log("SUCCESS");
When I click on the right object that has the movesample script attached, It directs to the correct pop up UI. When I clicked on the wrong object, it goes to the incorrect pop up. Here is an example of the correct UI:
What I want to do is have the ability to ONLY click on the button and nothing else. The triangles and background all null/unable to do anything. I have been looking into bools, event systems, if else statements, but not sure how to do this. If anyone could help I would GREATLY appreciate it. Thank you.