Having a hard time changing a color to a color i have stored in an array. The line that throws the error is the one in my update.
The error i am getting is this..
BCE0022: Cannot convert 'Object' to 'UnityEngine.Color'.
which makes sense, but im not sure how to correct it. I have tried using many methods, but still get this or other errors(based on the method used). Can someone please give me some insight as to what i am doing wrong and a solution. Thank you in advance.
asked Mar 15 '12 at 04:44 AM
Well, if you're not using any dynamic stuff, why not just use a builtin array and avoid that whole mess?
That way, your indexing will work properly.
By the way, the reason for your problem is that #pragma strict removes all dynamic typing. The practical upshot of this is that you can't just get a value out of an Array class- you need to cast it back to the type that you need it to be.
However, Unity's Array class is slow and badly typed, so you're better off just using the builtin one.
If you need the ability to dynamically add and remove objects (but the objects will only ever be of a single type), you might be better off using
This has Add and Remove methods, as well as some other things you might find useful. If that name is a bit too long for you, add a directive importing System.Collections.Generic at the top of your file.