I have created a scroll view in Unity, and wanted to make the elements inside clickable. It would function as a level select menu. The level panels are instantiated from a prefab.
As a first approach I added an IPointerClickHandler to the parent object (the background of the prefab, in grey)
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
public class ScrollViewItem : MonoBehaviour, IPointerClickHandler
{
public TextMeshProUGUI title, length;
public void initialize(string titleInit, float lengthInit)
{
title.text = titleInit;
length.text = "Length: " + lengthInit.ToString("F0") + "s";
}
public void OnPointerClick(PointerEventData eventData)
{
Debug.Log("hello");
}
}
It worked fine until yesterday, and today my Unity editor crashed because of CPU issues I assume, and now this does not work anymore. For some reason the IPointerClickHandler does not react at all, and also if I add a Button to the prefab, the Button stops working as well.
I don't know if it is helpful, but the hierarchy is built as following:
-canvas
--background
---content
----here the panels are instantiated
