An Il2Cpp SDK generator for Android (And probably IOS)
- Compile Il2CppSDK generator (or use release version)
- Get your DummyDll from using Il2CppDumper
- Drag the whole folder of DummyDll to Il2CppSDK.exe
- Wait for your SDK to be generated
- Copy the result to your project
- Copy precoded Il2Cpp Headers to your project (And include it to your Android.mk or CMakeList.txt)
Done!
You can include an namespace header to compile whole classes within a namespace or just compile a single class, for example take a look at SDK result.
Please read how to Initialize Il2Cpp Functions first before using any of the SDK/Il2Cpp Functions.
Example:
#include "SDK/Assembly-CSharp.dll/GameBase.h"
#include "SDK/Assembly-CSharp.dll/GameEngine.h"
#include "SDK/UnityEngine.dll/Includes/UnityEngine/Component.h"
#include "SDK/UnityEngine.dll/Includes/UnityEngine/Transform.h"
#include "SDK/UnityEngine.dll/Includes/UnityEngine/Screen.h"
#include "SDK/UnityEngine.dll/Includes/UnityEngine/Camera.h"
#include "SDK/UnityEngine.dll/Includes/UnityEngine/Physics.h"
#include "SDK/UnityEngine.dll/Includes/UnityEngine/RaycastHit.h"
#include "SDK/UnityEngine.dll/Includes/UnityEngine/Object.h"
using namespace UnityEngine;
using namespace GameBase;
using namespace GameEngine;
void PrintLocation()
{
auto baseGame = GamePlay::get_Game<BaseGame *>();
if (baseGame) {
auto localPawn = GamePlay::get_LocalPawn<Pawn *>();
if(localPawn){
auto pawnTransform = ((Component *)localPawn)->get_transform<Transform *>();
LOG("Local Pawn: %f %f %f", pawnTransform->get_position().x, pawnTransform->get_position().y, pawnTransform->get_position().z);
localPawn->m_Health() = 9999.9f;
}
}
}
Before you use any Il2Cpp
functions, you need to call Attach
first.
...
void WaitForAttach()
{
waitUntilLoaded(); // TODO: create function that loops when libil2cpp.so is not loaded yet.
if(Il2Cpp::Attach() != 0)
{
// Something goes wrong here...
exit(0);
}
// Attached!
// You can call any Il2Cpp functions now.
}
7 July 2020:
- Added CreateString functions to Il2Cpp Header
dnlib: dnlib