playMaker

Author Topic: Argument Out of Range Error for UI Pointer Enter Event on Canvas Prefab  (Read 1679 times)

westingtyler

  • Sr. Member
  • ****
  • Posts: 277
    • My Video Game Projects Web Site
Area: Editor in Play Mode
Frequency: Suddenly now always

1) What happened
In an FSM I have a UI On Pointer Enter Event that sends an event. Suddenly, now it also creates an error right after doing it. Everything seems to work fine, but the console is spammed with these errors as I hover over the various menu canvas item prefabs that contain this this fsm.


2) How can we reproduce it
the top event is what triggers it, in the picture.

billsmithnine@gmail.com

Unity Info:
Unity Version: 2019.3.15f1
Playmaker Version: 1.9.0.p20
BuildTarget: StandaloneWindows

System Info:
OS: Windows 10  (10.0.0) 64bit
Processor: AMD FX(tm)-8350 Eight-Core Processor
System Memory: 32749
Graphics Device: NVIDIA GeForce RTX 2060 SUPER



ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource) (at <437ba245d8404784b9fbab9b439ac908>:0)
System.ThrowHelper.ThrowArgumentOutOfRangeException () (at <437ba245d8404784b9fbab9b439ac908>:0)
System.Collections.Generic.List`1[T].get_Item (System.Int32 index) (at <437ba245d8404784b9fbab9b439ac908>:0)
UnityEngine.EventSystems.EventTrigger.Execute (UnityEngine.EventSystems.EventTriggerType id, UnityEngine.EventSystems.BaseEventData eventData) (at S:/Game Engines/2019.3.15f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/EventTrigger.cs:212)
UnityEngine.EventSystems.EventTrigger.OnPointerEnter (UnityEngine.EventSystems.PointerEventData eventData) (at S:/Game Engines/2019.3.15f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/EventTrigger.cs:223)
UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerEnterHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at S:/Game Engines/2019.3.15f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/ExecuteEvents.cs:22)
UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at S:/Game Engines/2019.3.15f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/ExecuteEvents.cs:261)
UnityEngine.EventSystems.EventSystem:Update() (at S:/Game Engines/2019.3.15f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/EventSystem.cs:377)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Hi,

 do you delete objects during the event called by these, maybe there is a race condition with this. do you load, unload scenes during this event?

is it now happening always or is it random?

Bye,

 Jean

westingtyler

  • Sr. Member
  • ****
  • Posts: 277
    • My Video Game Projects Web Site
I have a state with a UI On Pointer Enter Event. it sends its event and does a "next frame event" in another state, before returning to the pointer monitor. I've pinpointed that the error does NOT occur if I DISABLE the next frame event. process of elimination found the next frame event to be causing it. can you explain why?

I added that NF event to ensure it doesn't "double trigger" the ui pointer event. I just thought it was good practice to use NF events after inputs, but disabling the NF event in the prefab, makes the errors go away. why?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Hi,

 probably because the event exists only during the frame? always check inputs on the frame you receive them, that's for sure a safer approach. then move on to logic which can then have some frame delays and what not.

preventing double triggers is best done with a counter that you increment on pointer down and decrement on pointer up or cancel. then on pointer down event check that counter.

you can also put your UI in a canvasGroup and toggle block raycasts to prevent any pointer to have any effects on the whole UI.


Bye,

 Jean

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Hi.
In our project i have set a fsm that only checks enter / exit and sets a bool.
(it could also send a event tho)

Then on the other fsms i use a bool test.
This way there is no issue when the other fsm takes more than 1 frame.