Question by
$$anonymous$$ · Mar 31, 2017 at 10:01 AM ·
unity 5coroutinesdecompilereverse engineering
How can I get back the original code from this enumerator decompilation?
I am trying to decompile some code from an old unity project for which only the build is available (after an accident involving data loss). Most of the code is decompiled relatively well, but enumerators provide code like this:
[CompilerGenerated]
private sealed class <LoadFileTables>c__Iterator8 : IDisposable, IEnumerator, IEnumerator<object>
{
internal object $current;
internal int $PC;
internal DesignFileTableLoader<> f__this;
internal IEnumerator<iter> __1;
internal TableLoaderWorker<worker> __0;
[DebuggerHidden]
public void Dispose()
{
this.$PC = -1;
}
public bool MoveNext()
{
uint num = (uint)this.$PC;
this.$PC = -1;
switch (num)
{
case 0:
this.< worker > __0 = new TableLoaderWorker(this.<> f__this.TableReader);
this.< iter > __1 = this.<> f__this.LoadTable(this.< worker > __0, this.<> f__this._file.ElementTable, this.<> f__this.ElementTableStrategy);
break;
case 1:
break;
case 2:
goto Label_00EB;
case 3:
goto Label_0145;
case 4:
goto Label_019F;
case 5:
goto Label_01F9;
default:
goto Label_0210;
}
if (this.< iter > __1.MoveNext())
{
this.$current = null;
this.$PC = 1;
goto Label_0212;
}
this.< iter > __1 = this.<> f__this.LoadTable(this.< worker > __0, this.<> f__this._file.LayerTable, this.<> f__this.LayerTableStrategy);
Label_00EB:
while (this.< iter > __1.MoveNext())
{
this.$current = null;
this.$PC = 2;
goto Label_0212;
}
this.< iter > __1 = this.<> f__this.LoadTable(this.< worker > __0, this.<> f__this._file.SceneTable, this.<> f__this.SceneTableStrategy);
Label_0145:
while (this.< iter > __1.MoveNext())
{
this.$current = null;
this.$PC = 3;
goto Label_0212;
}
this.< iter > __1 = this.<> f__this.LoadTable(this.< worker > __0, this.<> f__this._file.MaterialTable, this.<> f__this.MaterialTableStrategy);
Label_019F:
while (this.< iter > __1.MoveNext())
{
this.$current = null;
this.$PC = 4;
goto Label_0212;
}
this.< iter > __1 = this.<> f__this.LoadTable(this.< worker > __0, this.<> f__this._file.StatisticsTable, this.<> f__this.StatisticsTableStrategy);
Label_01F9:
while (this.< iter > __1.MoveNext())
{
this.$current = null;
this.$PC = 5;
goto Label_0212;
}
this.$PC = -1;
Label_0210:
return false;
Label_0212:
return true;
}
[DebuggerHidden]
public void Reset()
{
throw new NotSupportedException();
}
object IEnumerator<object>.Current =>
this.$current;
object IEnumerator.Current =>
this.$current;
}
[CompilerGenerated]
private sealed class <LoadTable>c__Iterator9 : IDisposable, IEnumerator, IEnumerator<object>
{
internal object $current;
internal int $PC;
internal ITableLoadStrategy<$> strategy;
internal IDesignFileTable<$> table;
internal TableLoaderWorker<$> worker;
internal Exception<exception> __0;
internal ITableLoadStrategy strategy;
internal IDesignFileTable table;
internal TableLoaderWorker worker;
[DebuggerHidden]
public void Dispose()
{
this.$PC = -1;
}
public bool MoveNext()
{
uint num = (uint)this.$PC;
this.$PC = -1;
switch (num)
{
case 0:
this.worker.StartLoadingTable(this.table, this.strategy);
break;
case 1:
break;
default:
return false;
}
if (!this.worker.IsFinished)
{
this.$current = null;
this.$PC = 1;
return true;
}
this.< exception > __0 = this.worker.BackgroundThreadException;
if (this.< exception > __0 != null)
{
throw this.< exception > __0;
}
this.$PC = -1;
}
[DebuggerHidden]
public void Reset()
{
throw new NotSupportedException();
}
object IEnumerator<object>.Current =>
this.$current;
object IEnumerator.Current =>
this.$current;
}
}
I don't really understand how it works or how to rewrite it, what's going on with those dollared variables and gotos?
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612114350im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to interrupt wait coroutine in a loop? 0 Answers
Fade out / fade in scene w/ loading screen 0 Answers
Unity MVC animation coroutine 0 Answers
Pass a context object to Android from C# 0 Answers