Created
November 10, 2020 23:09
-
-
Save charlieamat/372001589fd7927eff7aeecdb46ca92b to your computer and use it in GitHub Desktop.
An example of the compiler generating classes for anonymous functions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEngine.Events; | |
public class SimpleClass : MonoBehaviour | |
{ | |
private UnityEvent _event; | |
private void Awake() | |
{ | |
_event.AddListener(() => | |
{ | |
Debug.Log("Fire!"); | |
}); | |
} | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Runtime.CompilerServices; | |
using UnityEngine; | |
using UnityEngine.Events; | |
public class SimpleClass : MonoBehaviour | |
{ | |
private UnityEvent _event; | |
private void Awake() | |
{ | |
// ISSUE: method pointer | |
this._event.AddListener(SimpleClass.<>c.<>9__1_0 ?? (SimpleClass.<>c.<>9__1_0 = new UnityAction((object) SimpleClass.<>c.<>9, __methodptr(<Awake>b__1_0)))); | |
} | |
public SimpleClass() | |
{ | |
base.\u002Ector(); | |
} | |
[CompilerGenerated] | |
[Serializable] | |
private sealed class <>c | |
{ | |
public static readonly SimpleClass.<>c <>9; | |
public static UnityAction <>9__1_0; | |
static <>c() | |
{ | |
SimpleClass.<>c.<>9 = new SimpleClass.<>c(); | |
} | |
public <>c() | |
{ | |
base.\u002Ector(); | |
} | |
internal void <Awake>b__1_0() | |
{ | |
Debug.Log((object) "Fire!"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment