ByNameModding / BNM-Android

Modding il2cpp games by classes, methods, field names on Android.
MIT License
176 stars 37 forks source link

How to invoke static method #36

Closed ice5355 closed 1 month ago

ice5355 commented 1 month ago

How to invoke static method in BNM , the c# code like var button3 = GameObject.Find("Button (3)");

ballsofsoul commented 1 month ago

assuming you are using latest BNM

  1. Get Gameobject class auto GameObjectClass = BNM::Class("UnityEngine", "GameObject");
  2. Get needed method (Find) from class BNM::Method<void*> GameObject_Find = GameObjectClass.GetMethod("Find", 1);
  3. Call this method auto button3_go = GameObject_Find.Call(String::Create("Button (3)"));
ice5355 commented 1 month ago

Thank you!