Access to Modified Cloosure

880 ワード

http://stackoverflow.com/questions/235455/access-to-modified-closure 1.dotweenを使ってイベントを処理する時に、類似コードを書いたらfor (int i = 0; i < MazeController.Instance.CurrentData.StarNum; i++) { //var index = i; starPositon[i].DOLocalMove(new Vector3(630f, 390f, 0), 1f).From().SetDelay(0.3f*(i+1)).OnComplete( delegate { this.GlowSofts[i].SetActive(true); this.StarFulls[i].SetActive(true); }); }にAccess to Modified Closeureを提示し、activeを設定するすべての値は固定された最後の値になり、異常を報告することもあります。同じ問題がLIQの使用にもあるかもしれません。http://www.cnblogs.com/wintersun/archive/2010/06/15/1758628.html 2.i値を記録し、クローズドにアクセスしないとfor (int i = 0; i < MazeController.Instance.CurrentData.StarNum; i++) { var index = i; starPositon[i].DOLocalMove(new Vector3(630f, 390f, 0), 1f).From().SetDelay(0.3f*(i+1)).OnComplete( delegate { this.GlowSofts[index].SetActive(true); this.StarFulls[index].SetActive(true); }); }