Using C# and JS together, List types won't agree
I'm trying to convert a medium sized JS game into C# because JS support is sunsetting in the near future. I'm trying to make sure the game is working as I convert so I'm doing it file by file. I'm moving the newly created C# files into a plugin folder so their classes are still accessible to the JS.
I'm stuck on one C# file where a function inside operates on a parameter typed as a generic List, however Unity keeps thinking it's an ArrayList, so it won't work. Does anyone know how I can get the function to pass Unity's checks?
The call from my JS file:
print("CHECK TYPE");
print(spawnerList.GetType());
Y_Util.RandomizeArray(spawnerList);
Prints out System.Collections.Generic.List`1[System.Object]
The function in my C# file:
public static void RandomizeArray(List<Object> arr){
for (int i = arr.Count - 1; i > 0; i--) {
int r = Random.Range(0, i + 1);
Object tmp = arr[i];
arr[i] = arr[r];
arr[r] = tmp;
}
}
But when I run the game with everything, I get this error:
The best overload for the method 'Y_Util.RandomizeArray(System.Collections.ArrayList)' is not compatible with the argument list '(System.Collections.Generic.List.)'.
Your answer
![](https://koobas.hobune.stream/wayback/20220612153521im_/https://answers.unity.com/themes/thub/images/avi.jpg)