jeudi 1 août 2019

C# Assembly "Overloading" at runtime (Unity3D)

This is possibly a duplicate of other questions regarding Reflection and Overloading, etc, but I think I'm struggling because I don't know what to actually call this problem so I'm not Googling it properly.

Anyway, I've got two programs. One is a 'launcher' and another is the 'guts'.

The launcher has a class defined:

public static class TestAsmdef {
  public static void DoTest() {
    Debug.Log("Version 0");
  }
}

The guts then have the exact same class defined but with different debug message:

public static class TestAsmdef {
  public static void DoTest() {
    Debug.Log("Version 1");
  }
}

Within the launcher, I'm loading the guts assembly via:

  TestAsmdef.DoTest();
  Assembly.Load(unityAssetBundle.LoadAsset<TextAsset>("guts").bytes);
  TestAsmdef.DoTest();

I'd hope to see debug output:

0
1

But as you probably guess, I'm seeing:

0
0

I know the assembly load is definitely working as classes that do not exist at all in the launcher are available from guts after the load, but I'm not properly overloading existing classes. Any idea on what I'm doing wrong or what this concept is called so I can better search for a solution?





Aucun commentaire:

Enregistrer un commentaire