- Home /
How can I get the PointerEventData included in StandaloneInputModule ?
Hi guys,
I want to access to the "PointerEventData" object which is part of the "StandaloneInputModule" in Unity, in order to know which gameobject is pointed at each frame. (Not necessarily those with a collider, but also UI gameobjects etc...)
The problem is that the PointerEventData included in the StandaloneInputModule is declared as a protected property.
So I created this class, which inherits from StandaloneInputModule :
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class StandaloneInputModuleCustom : StandaloneInputModule
{
public PointerEventData GetLastPointerEventDataPublic(int id)
{
return GetLastPointerEventData(id);
}
}
Using this, I have access to all the informations I need at each frame. And I can know which gameobject is touched etc... by using this PointerEventData getter.
It works perfectly in the editor, but when I start the game on Android or iOS after building it, I get a NullReferenceException at the moment I call the "GetLastPointerEventDataPublic" method.
It just doesn't work with a real build, I cannot access to the PointerEventData of the StandaloneInputModule, except in the editor.
Does anyone knows why ?
Thank you :)
Your answer
![](https://koobas.hobune.stream/wayback/20220612101142im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Why my pointer events keep triggering 3 times all the time??? 1 Answer
Windows 8 / Store App: Inputs (WM_POINTER) 0 Answers
IPointerEnterHandler / IPointerExitHandler and touch 1 Answer
IPointerEnterHandler doesn't work when object switches parent 1 Answer
Different Jump Heights: Input.GetKey vs Pointer Down 1 Answer