So I have multiple gameobjects that needs to be interactable and I've put them all in one gameobject container. But the thing is I still have to attach the script into each of the gameobjects that needs to be interactable for it to work and that seems kinda iffy when a scenario comes that I have to add more gameObjects.
Is it possible to just put the script in the container object? I tried this on my container object and I'm pretty sure I'm doing something wrong.
public GameObject spriteHandler;
GameObject sprite1;
GameObject sprite2;
GameObject sprite3;
private void Start()
{
sprite1 = spriteHandler.transform.GetChild(0).gameObject;
sprite2 = spriteHandler.transform.GetChild(1).gameObject;
sprite3 = spriteHandler.transform.GetChild(2).gameObject;
}
void OnMouseDown()
{
Debug.Log("Clicked");
}