Question by
Haobo38 · Oct 18, 2021 at 04:30 PM ·
inputevent triggeringpointeroverride
Why my pointer events keep triggering 3 times all the time???
Hello everyone i'm having a really odd problem and i really do need some help or tips . So i followed a video of VR pointer where I try to override the input as following :
public class VRInput : BaseInput
{
public Camera eventCamera = null;
public SteamVR_Input_Sources m_TargetSource;
public SteamVR_Action_Boolean m_ClickAction;
public PhysicsPointer m_PhysicsPointer = null;
protected override void Awake()
{
GetComponent<BaseInputModule>().inputOverride = this;
}
public override bool mousePresent
{
get
{
return true;
}
}
public override bool GetMouseButton(int button)
{
return m_ClickAction.GetState(m_TargetSource);
}
public override bool GetMouseButtonDown(int button)
{
return m_ClickAction.GetStateDown(m_TargetSource);
}
public override bool GetMouseButtonUp(int button)
{
return m_ClickAction.GetStateUp(m_TargetSource);
}
public override Vector2 mousePosition
{
get
{
Vector3 screenPos = eventCamera.WorldToScreenPoint(m_PhysicsPointer.GetDotPosition());
return new Vector2(screenPos.x, screenPos.y);
}
}
}
and after this change of inputOverride, when I try to invoke a onpointerdown event, like :
public void OnPointerDown(PointerEventData eventData)
{
Debug.Log("OnPointerdonw");
}
after a single pointerdown action(in my case pushing a button on my htc vive controller), I'll get 3 "OnpointerDown" messages and I have no idea why I'm having that .
Any help or ideas about where it comes the problems are greatly appreciated!
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613044327im_/https://answers.unity.com/themes/thub/images/avi.jpg)