The following returns the following error:
Line 11: InvalidCastException: Cannot cast from source type to destination type.
It works perfectly with anything that inherits from UnityEngine.Object. I don't understand how to prevent this from happening with .net datatypes.
void Start () {
float[] f = new float[5];
f[0] = 4.5f;
Test(f);
}
void Test(object t)
{
if (t is Array)
{
Debug.Log("isarray");
object[] a = (object[])t;
if (a[0] is float)
{
Debug.Log("isfloat");
}
}
}