Hi all,
I have recently installed Unity 1.5, but when I import my project that I’ve made in version 1.2, I get some errors related to the .NET-arrays that I’ve used.
For instance, a line in my code reads:
inventoryArray.Contains(p_data.person_oensker[1])
and the error I get is:
“Contains” is not a member of “Array”.
I also get the same error with Remove, IndexOf and Insert.
So:
- either Otee has removed a lot of stuff from the .NET-array class, which is very bad indeed
- or Unity 1.5 thinks that my array is a javascript-array and thats why its fucked up.
But how do I check what type my array is - and if it turns out to be a JS-array, how do I convert it from JS to .NET ??
alright, so I’ve narrowed it down a bit:
if I add one line of code to my script (in the files SET_budbringerproperties.js) I get this code that defines my array:
var budbringer_objects_index = Array(5); //objects
var budbringer_objects_index : Vector3[ ] = budbringer_objects_index.ToBuiltin(Vector3);
The first line is the original array-variable and the second is meant to convert the array to a .NET-type. This code only generates one error (in comparison to the 15 errors I previously got):
Type “SET_budbringerproperties” already has a definition for “budbringer_objects_index”.
I declare the variable two times, so the error is understandable, but if I remove the “var” from the second line of code, I get another error.
Anyone got any bright ideas?
Unity 1.5 has javascript style arrays. Unity 1.2.2 had .NET style arrays. So the api is a bit different now.
http://unity3d.com/Documentation/ScriptReference/Array.html
If you want to continue using .NET arrays you can use the ArrayList class which is the same as the 1.2.2 Array class. (Just replace all occurrences of Array with ArrayList)
Sorry for the inconvenience in switching to javascript style arrays.
(Web players are backwards compatible with this btw. It only happens when you recompile scripts)