I have Canvas and all UI components are put inside as shown in the image. There is a ScriptObject to implement C# script (Historyscript.cs) for handling the UI. Historyscript.cs is attached to ScriptObject and Dropdown has link to the script and Dropdown component is working. Now I like to detect Dropdown component is clicked in Unity.
What I do is in the Historycanvas,
public void OnPointerClick(BaseEventData eventData) is added.
using UnityEngine.EventSystems;
public class Historycanvas : MonoBehaviour, IPointerClickHandler
{
void Start(){}
public void OnPointerClick(BaseEventData eventData)
{
Debug.Log(" was selected");
}
// Update is called once per frame
void Update () {
}
}
To have linked that public void OnPointerClick(BaseEventData eventData)
to Dropdown object, I added ScriptObject to Dropdown's function link.
Inside we can find Historycanvas class, but there is no OnPointerClick function to link. What could be the issue?
EDIT:
This question is different from Programmer's link as he implemented Callback function, but my implementation is different. He used onValueChanged(), but I like to implement OnPointerClick() or onSelect()
. I can't add AddListener() to OnPointerClick() or onSelect()
.