I have two scripts a parent and a child. The parent script provides the On Mouseover method for the child to use if Input.("Fire1") is used. and then it SHOULD disable the collider the mouse is over and score a point. But I am having an error where if I click on one prefab collider with the child script attached, it will then disable all prefab game objects. how can I fix this so my child script only allows for one disabling of a prefab at a time?
Parent Script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CollectableParent : MonoBehaviour
{
protected GameManager gameManager;
// Start is called before the first frame update
void Awake()
{
gameManager = GameObject.Find("GameManager").GetComponent<GameManager>();
}
// Update is called once per frame
void Update()
{
}
public void OnMouseOver()
{
if (Input.GetButtonDown("Fire1"))
{
this.gameObject.SetActive(false);
gameManager.UpdateScore(5);
}
}
}
ChildScript
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LevelOneJack : CollectableParent
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetButtonDown("Fire1"))
{
OnMouseOver();
}
}
}