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 IPointerClickHandlerIPointerClickHandler to the parent object (the background of the prefab, in gerygrey)
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");
}
}
itIt worked fine until yesterday, and today my unityUnity editor crashed because of cpuCPU issues iI assume, and now this does not work anymore. For some reason the IPointerClickHandlerIPointerClickHandler does not react at all, and also if I add a ButtonButton to the prefab, the buttonButton stops working as well.
I dontdon't know if it is helpful, but the hierachyhierarchy is built as following:
-canvas
--background
---content
----here the panels are instantiated
