playMaker

Author Topic: A ArgumentOutOfRangeException occurs when switch State  (Read 370 times)

sasalicat

  • Playmaker Newbie
  • *
  • Posts: 1
A ArgumentOutOfRangeException occurs when switch State
« on: July 21, 2022, 09:50:21 AM »
this is my state mechine
In canPick state if mouse enter gameObject, it will translates to force state
(in image attachment 2)
then,if it in focus state,there are two case.if mouse leaves gameObject it will translate back to canPick state.but if mouses click gameObject it will translate to
click state
 (in image attachment 1)
It look well,but when mouse leaves gameObject in focus state a ArgumentOutOfRangeException will be throw by EventSystem
 (in image attachment 3)
I try solve this by myself before I come here.I user break point to debug,then I have a guess on my mind.look at  (in image attachment 4)
Code: [Select]
        private void Execute(EventTriggerType id, BaseEventData eventData)
        {
            var triggerCount = triggers.Count;

            for (int i = 0, imax = triggers.Count; i < imax; ++i)
            {
                var ent = triggers[i];
                if (ent.eventID == id && ent.callback != null)
                    ent.callback.Invoke(eventData);
            }

        }
It`s seem like player maker modify triggers in this for loop.do you guys remeber?there are two pointer listeners in focus state but only one in canPick state. I guess variable trigger has been harshly assigned when switch back to canPick state,at that time for loop has not been finish,i++ make i become 2,but canPick state have only 1 pointer listener,so a ArgumentOutOfRangeException be throw.

Maybe there is something wrong with the way I use PlayMaker.Can you guys tell me a right way to handle this use case?As a beginer I still have a lots to learn .thanks. :)
another question "The upload folder is full. Please try a smaller file and/or contact an administrator." I think I can post picture attachment here
« Last Edit: July 21, 2022, 09:52:49 AM by sasalicat »