I am currently working on a system which allows to switch through different widget children of an array. By pressing left or right I am able to switch to the widget with value one less/more than the current widget. I also implemented some logic so that when reaching the outer limits it would loop back to the opposite side.
This works fine for the most part. I can go fully from left to right without any issues but once I try to go left I get stuck at the maximum value, in this case the array value 5. After doing a little debugging I found out that my array loses the widgets number 4 and replaces it with number 5. Creating an infinite loop where number 5 always calls number 5.
There’s nothing in the script we see here that could be causing it. The issue is where you tamper with it, where cannot see
After doing a little debugging I found out that my array loses the widgets number 4 and replaces it with number 5. Creating an infinite loop where number 5 always calls number 5.
All we can see is that you had 6 elements, and now you have 5.
how do you populate the array?
does it have default value?
do you Add / Remove or Set Array Elements anywhere?
Corect, I am investigating the change in size. Unfortunately following your example the length doesnt get printed at all. I will try a different construction to test the length
So with a different construction I can now read the length. Going right the length stays at 6 always, going left when reaching the last index the length goes to 5
There’s nothing in this script that could affect the length of that array. Set up break points and step through the script, see what you can find out.
This would cycle through all the widgets with a two-way rollover. I’ve ignored the fact that the widgets are never removed and just keep overlapping infinitely.
In order to get rid of widget 4, you’d need to explicitly remove that index.
If you don’t, and the array is not accessed anywhere else, chances are you’ve run into an unorthodox bug no one has ever heard about. It’s definitely not impossible.
If you ever figure out what is causing it, do tell!
For now, perhaps make a new array variable and see if the issue still manifests.
So it turns out if I just create a new Array with the same indexes it works.
Its strange but I guess it works now. I had a similar situation when i ahd a specific widget not working. Deleting it and recreating an identical one fixed the issue.