Hey I found weird stuff that my brain can’t explain why this happens.
I’m learning mesh rendering and using catlikecoding website for tutorials. (Square Grid) I finished section #1.6. When I did press run I got this error:
ArgumentException: Index buffer element #0 (value 1953066581) is out of bounds; mesh only has 4 vertices.
Any clue why do I get this insane index value?
I did check the code many many times, but can’t find anything.
I had the same problem,but it worked fine after I was rewriting(but I didn’t change it)the variable name of SingleStream,I think this is a problem or a error with the code editor(VS).
You don’t need to post code, you need to debug code.
Just because this code came from a tutorial, it still might need debugging for any number of reasons.
In any case, staring at code is almost never a useful approach to fixing it.
And that is why we have debugging.
First, just some information about this specific bug:
Here are some notes on IndexOutOfRangeException and ArgumentOutOfRangeException:
Steps to success:
find which collection it is and what line of code accesses it <— (critical first step!)
find out why it has fewer items than you expect
fix whatever logic is making the indexing value exceed the collection size
Remember also:
a collection with ZERO elements cannot be indexed at all: it is empty
you might have more than one instance of this script in your scene/prefab
the collection may be used in more than one location in the code
indices start at ZERO (0) and go to the count / length minus 1.
This means with three (3) elements in your collection, they are numbered 0, 1, and 2 only.
Finally, here’s how to begin your debugging adventures:
Sounds like you wrote a bug… and that means… time to start debugging!
By debugging you can find out exactly what your program is doing so you can fix it.
Use the above techniques to get the information you need in order to reason about what the problem is.
You can also use Debug.Log(...); statements to find out if any of your code is even running. Don’t assume it is.
Once you understand what the problem is, you may begin to reason about a solution to the problem.
Remember with Unity the code is only a tiny fraction of the problem space. Everything asset- and scene- wise must also be set up correctly to match the associated code and its assumptions.