i have this script where i click on my cubes and they turn to their respective color, but i can also change to the ball color and i dont want that. is there a way to make my ball unclickable? i’ve tried this so far but no success
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class ChangeBallColor : MonoBehaviour
{
[SerializeField] GameObject ball;
[SerializeField] Material ballMaterial;
[SerializeField] Material cubeMaterial;
// Start is called before the first frame update
void Start()
{
Debug.Log(FindObjectOfType<ChangeBallColor>().gameObject);
}
// Update is called once per frame
void Update()
{
}
private void OnMouseDown()
{
if (EventSystem.current.IsPointerOverGameObject() == false)
{
ballMaterial.color = cubeMaterial.color;
}
if(ball)
{
return;
}
}
}