https://docs.unity3d.com/ja/2022.3/Manual/UIE-Mouse-Events.html
ここのランタイムの例にコード載ってるので、それやってみて