LoginSignup
3
0

More than 5 years have passed since last update.

【Unity】コルーチンでtry catchした時に起きるエラー

Last updated at Posted at 2016-12-26

先日Unityのコルーチンのコードを書いていて
謎のコンパイルエラーに遭遇したので.....φ(´・ω・`)カキカキ♪

原因を調べたら.Net側の問題なのかな?
とにかくIEnumrator型のメソッド内でtry catchを使うときに出るエラーのようです

using System;
using System.Collections;

public class IEnumratorTryCatchError
{
    IEnumerator test()
    {
        try
        {
        }
        catch (Exception e)
        {
        }
        yield break;
    }
}

このようにcatchしたExceptionを未使用の時にのみ起こるエラーのようです。
しかも全く関係ないクラスがErrorログに出てくるので、この記述が原因だと特定するのに苦労します・・・

image

ちなみにvoid型のメソッドではエラーになりませんでした

using System;
using System.Collections;

public class IEnumratorTryCatchError
{
    void Test()
    {
        try
        {
        }
        catch (Exception e)
        {
        }
    }
}
3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0