- Home /
Question by
Mihaaa_123_123 · Mar 12, 2017 at 11:36 AM ·
unity 5enumeratedecompile
Decompililing Unity Assembly-CSharp IEnumerator
Hi! I decompiled some code from my old Unity project. i used dotPeek to decomile my code and almost everything worked great! except this code:
[DebuggerHidden]
private IEnumerator EndShield()
{
// ISSUE: object of a compiler-generated type is created
return (IEnumerator) new ShieldPowerup.\u003CEndShield\u003Ec__Iterator4()
{
\u003C\u003Ef__this = this
};
}
Whole decompiled Script:
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using UnityEngine;
public class ShieldPowerup : BasePowerup
{
private float RandomShieldTimer;
private GamePlayManager Manager;
protected override void ActivatePowerup(Collider2D Player, GamePlayManager Manager)
{
this.Manager = Manager;
this.RandomShieldTimer = 10f;
this.SetShields(true);
this.StartCoroutine("EndShield");
this.Graphic.SetActive(false);
}
private void SetShields(bool State)
{
using (List<HitObject>.Enumerator enumerator = this.Manager.GetHitObjects().GetEnumerator())
{
while (enumerator.MoveNext())
enumerator.Current.toggleShield(State);
}
}
[DebuggerHidden]
private IEnumerator EndShield()
{
// ISSUE: object of a compiler-generated type is created
return (IEnumerator) new ShieldPowerup.\u003CEndShield\u003Ec__Iterator4()
{
\u003C\u003Ef__this = this
};
}
private void StopShield()
{
this.SetShields(false);
Object.Destroy((Object) this.gameObject);
}
}
How ti fix this code? please help me
Comment
Best Answer
Answer by tanoshimi · Mar 12, 2017 at 02:45 PM
While decompilers like dotPeek can easily extract source from trivial code methods of a .NET library, certain constructs such as IEnumerators cannot be reverse-engineered quite so readily, so you'll have to refer to your original source code. If you don't have that anymore, I recommend you look into version control and backup systems for your current projects to prevent the same problem happening in the future.
Your answer
![](https://koobas.hobune.stream/wayback/20220612113017im_/https://answers.unity.com/themes/thub/images/avi.jpg)