Hi
I’m implementing my own data structure which makes use of C# IEnumerator. I have functions like this which return Status objects:
public IEnumerator Execute()
{
yield return Status.Suceeded;
}
Then I’m checking the return value like so:
Status result = status.Current as Status;
But in the normal course of execution over this data structure (it’s a tree), status.Current can be null, which should mean that the “as” cast will return null and set result to null. However, when I run this in the Unity iPhone Editor (version 1.0.1f3 (19262), I get an exception:
“InvalidOperationException: Operation is not valid due to the current state of the object”.
After a bit of investigation, I’m assuming the status.Current is null and the as is failing? If this is the case, this isn’t expected C# :?
Edit: The exception is also thrown in none-iPhone Unity 2.5 and 2.1