Skip to main content
fixed typos, added code markdown
Source Link
Pikalek
  • 13.4k
  • 5
  • 49
  • 54

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)

the level prefab

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

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 gery)

the level prefab

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 dont know if it is helpful, but the hierachy is built as following:

-canvas

 --background

 ---content

 ----here the panels are instantiated

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)

the level prefab

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

added 8 characters in body
Source Link
CheckerT
  • 176
  • 10

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 gery)

the level prefab

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 dont know if it is helpful, but the hierachy is built as following:   

-canvas   

--background   

---content   

----here the panels are instantiated

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 gery)

the level prefab

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 dont know if it is helpful, but the hierachy is built as following:  -canvas  --background  ---content  ----here the panels are instantiated

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 gery)

the level prefab

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 dont know if it is helpful, but the hierachy is built as following: 

-canvas 

--background 

---content 

----here the panels are instantiated

added 148 characters in body
Source Link
CheckerT
  • 176
  • 10

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 gery)

the level prefab

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 dont know if it is helpful, but the hierachy is built as following: -canvas --background ---content ----here the panels are instantiated

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 gery)

the level prefab

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 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 gery)

the level prefab

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 dont know if it is helpful, but the hierachy is built as following: -canvas --background ---content ----here the panels are instantiated

Don't repeat tags in title
Link
DMGregory
  • 141k
  • 23
  • 258
  • 401
Loading
deleted 8 characters in body
Source Link
CheckerT
  • 176
  • 10
Loading
Source Link
CheckerT
  • 176
  • 10
Loading