コガネブログ

平日更新を目標に Unity や C#、Visual Studio、ReSharper などのゲーム開発アレコレを書いていきます

【Unity】EventSystem.current.IsPointerOverGameObject が検出したゲームオブジェクトを取得できる StandaloneInputModule

リポジトリ

使用例

using Kogane;
using UnityEngine;
using UnityEngine.EventSystems;

public class Example : MonoBehaviour
{
    [SerializeField] private CustomStandaloneInputModule m_module;

    private void Update()
    {
        if ( EventSystem.current.IsPointerOverGameObject() )
        {
            // EventSystem.current.IsPointerOverGameObject が検出したゲームオブジェクトを取得
            var lastPointerGameObject = m_module.GetLastPointerGameObject();

            Debug.Log( lastPointerGameObject, lastPointerGameObject );
        }
    }
}