Pretty standard stuff. The problem though is that line 606 in FixtureController is this:
And that’s simply the closing bracket to the function. So basically Unity is telling me nothing more informative than “you have an argument out of range exception” in this function, whereas it used to give the actual line that causes the error.
Any assistance would be much appreciated because debugging is very tough right now.
So after a lot of unnecessary fiddling I finally got Unity to switch back from VS Code to Visual Studio. I can now confirm that the problem still persists with Visual Studio.
Out of curiosity, I reproduced your example in MonoDevelop and the error message in Unity points to line 17 instead of 16, the same way it does for you:
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 <fb001e01371b4adca20013e0ac763896>:0)
System.ThrowHelper.ThrowArgumentOutOfRangeException () (at <fb001e01371b4adca20013e0ac763896>:0)
Test.Start () (at Assets/Test.cs:17)
By the way I very much doubt this has anything to do with your code editor. By the time the Unity game is running Unity has compiled the game all by itself.
Surely the bug should point to line 19, no? If I have a function with 100’s of lines of code, how would I know where the ArgumentOutOfRangeException occured?
Not really, I’ve recently noticed an inconsistency in the error messages in Unity. The error specified that “;” was expected although the “=” assignment operator was missing in a line; and if I remember correctly, it also mentioned the wrong line number.
Out of those 3 loops, the first and third should work but the third should fail when ii = 3.
The error points to line 44, i.e the ending curly brace, and one would have no idea a priori where the error occured.
Are you able to reproduce this? Thank you again so much for your help.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PleaseWork : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
List<int> testList1 = new List<int>();
List<int> testList2 = new List<int>();
List<int> testList3 = new List<int>();
testList1.Add(0);
testList1.Add(1);
testList1.Add(2);
testList2.Add(0);
testList2.Add(1);
testList2.Add(2);
testList3.Add(0);
testList3.Add(1);
testList3.Add(2);
for (int ii = 0; ii <= 1; ii++)
{
testList1[ii]++;
}
for (int ii = 0; ii <= 5; ii++)
{
testList2[ii]++;
}
for (int ii = 0; ii <= 2; ii++)
{
testList3[ii]++;
}
}
// Update is called once per frame
void Update()
{
}
}
I meant after the faulty line, only one is enough. Try drowning it among many other correct Debug.Log lines and see what line the error message points at.
Have you ever come across this issue with ArgumentOutOfRangeExceptions?
Do you have any other suggestions? I’ve spent about 12 hours trying to fix this so far and I only have limited time time off my real job to work on it so it’s been incredibly frustrating being unable to do so.
Don’t think there is anything more about Unity/VS that I can re-install, and this is a brand new project. My main project literally is 10’s of thousands of lines long so I can hardly be swamping it with Debug.Log statements everywhere.