### Get Function Address and Invoke Methods Source: https://github.com/issuimo/unityresolve.hpp/blob/main/README.md Demonstrates how to retrieve function addresses and variable offsets from Unity assemblies, classes, and methods. It also shows how to invoke methods with specified arguments and return types, and how to cast methods for different signature uses. ```c++ const auto assembly = UnityResolve::Get("assembly.dll | 程序集名称.dll"); const auto pClass = assembly->Get("className | 类名称"); // assembly->Get("className | 类名称", "*"); // assembly->Get("className | 类名称", "namespace | 空间命名"); const auto field = pClass->Get("Field Name | 变量名"); const auto fieldOffset = pClass->Get("Field Name | 变量名"); const int time = pClass->GetValue(obj Instance | 对象地址, "time"); // pClass->GetValue(obj Instance*, name); = pClass->SetValue(obj Instance | 对象地址, "time", 114514); // pClass->SetValue(obj Instance*, name, value); const auto method = pClass->Get("Method Name | 函数名"); // pClass->Get("Method Name | 函数名", { "System.String" }); // pClass->Get("Method Name | 函数名", { "*", "System.String" }); // pClass->Get("Method Name | 函数名", { "*", "", "System.String" }); // pClass->Get("Method Name | 函数名", { "*", "System.Int32", "System.String" }); // pClass->Get("Method Name | 函数名", { "*", "System.Int32", "System.String", "*" }); // "*" == "" const auto functionPtr = method->function; const auto method1 = pClass->Get("method name1 | 函数名称1"); const auto method2 = pClass->Get("method name2 | 函数名称2"); method1->Invoke(114, 514, "114514"); // Invoke(args...); // Cast(void); // Cast(UnityResolve::MethodPointer&); const UnityResolve::MethodPointer ptr = method2->Cast(); ptr(114514, true); UnityResolve::MethodPointer add; ptr = method1->Cast(add); std::function add2; method->Cast(add2); UnityResolve::Field::Variable syncPos; syncPos.Init(pClass->Get("syncPos")); auto pos = syncPos[playerInstance]; auto pos = syncPos.Get(playerInstance); ``` -------------------------------- ### Get GameObject Components Source: https://github.com/issuimo/unityresolve.hpp/blob/main/README.md Demonstrates how to retrieve components attached to a GameObject, including searching in children and parents. It allows specifying the component type and optionally a class pointer. ```c++ std::vector objs = gameobj->GetComponents(UnityResolve::Get("assembly.dll")->Get("class"))); // gameobj->GetComponents(Class* component) std::vector objs = gameobj->GetComponentsInChildren(UnityResolve::Get("assembly.dll")->Get("class"))); // gameobj->GetComponentsInChildren(Class* component) std::vector objs = gameobj->GetComponentsInParent(UnityResolve::Get("assembly.dll")->Get("class"))); // gameobj->GetComponentsInParent(Class* component) ``` -------------------------------- ### Get Inherited Subclass Name Source: https://github.com/issuimo/unityresolve.hpp/blob/main/README.md Explains how to obtain the full name of an inherited subclass from a given base class instance. This involves finding an object of a base type and then querying its runtime type information. ```c++ const auto assembly = UnityResolve::Get("UnityEngine.CoreModule.dll"); const auto pClass = assembly->Get("MonoBehaviour"); Parent* pParent = pClass->FindObjectsByType()[0]; std::string child = pParent->GetType()->GetFullName(); ``` -------------------------------- ### Initialize UnityResolve Source: https://github.com/issuimo/unityresolve.hpp/blob/main/README.md This code demonstrates the initialization of the UnityResolve library. It requires a DLL handle (for Windows) or a shared object handle (for Linux/Android) and specifies the mode of operation (Mono or Il2cpp). ```C++ UnityResolve::Init(GetModuleHandle(L"GameAssembly.dll | mono.dll"), UnityResolve::Mode::Mono); // Linux or Android UnityResolve::Init(dlopen(L"GameAssembly.so | mono.so", RTLD_NOW), UnityResolve::Mode::Mono); ``` -------------------------------- ### Create C# Instance Source: https://github.com/issuimo/unityresolve.hpp/blob/main/README.md Shows how to instantiate a new C# object of a given class. This is useful for creating new game entities or components dynamically. ```c++ const auto assembly = UnityResolve::Get("assembly.dll | 程序集名称.dll"); const auto pClass = assembly->Get("className | 类名称"); const auto pGame = pClass->New(); ``` -------------------------------- ### Include GLM and UnityResolve.hpp Source: https://github.com/issuimo/unityresolve.hpp/blob/main/README.md This snippet demonstrates how to include the necessary headers for using GLM (a C++ mathematics library) and UnityResolve.hpp. It requires defining USE_GLM before including UnityResolve.hpp. ```C++ #define USE_GLM #include "UnityResolve.hpp" ``` -------------------------------- ### Create C# String Source: https://github.com/issuimo/unityresolve.hpp/blob/main/README.md Demonstrates how to create a C# string object using the UnityResolve library. It shows the creation of a new string and its conversion to a C++ std::string. ```c++ const auto str = UnityResolve::UnityType::String::New("string | 字符串"); std::string cppStr = str.ToString(); ``` -------------------------------- ### Load Mono Assembly Source: https://github.com/issuimo/unityresolve.hpp/blob/main/README.md This code demonstrates how to load a Mono assembly using UnityResolve. It shows two ways: a simple load and a more detailed load specifying the assembly, namespace, class, and method to execute. ```C++ UnityResolve::AssemblyLoad assembly("./MonoCsharp.dll"); UnityResolve::AssemblyLoad assembly("./MonoCsharp.dll", "MonoCsharp", "Inject", "MonoCsharp.Inject:Load()"); ``` -------------------------------- ### Obtain Instances by Type Source: https://github.com/issuimo/unityresolve.hpp/blob/main/README.md Demonstrates how to find and retrieve all instances of a specific type within the Unity scene. It returns a std::vector of pointers to the found objects. ```c++ const auto assembly = UnityResolve::Get("assembly.dll | 程序集名称.dll"); const auto pClass = assembly->Get("className | 类名称"); std::vector playerVector = pClass->FindObjectsByType(); // FindObjectsByType(void); playerVector.size(); ``` -------------------------------- ### Dump Data to File Source: https://github.com/issuimo/unityresolve.hpp/blob/main/README.md Provides a utility function to dump data to a specified directory. This is useful for exporting game state or debugging information. ```c++ UnityResolve::DumpToFile("./output/"); ``` -------------------------------- ### Create C# Array Source: https://github.com/issuimo/unityresolve.hpp/blob/main/README.md Illustrates the creation of a C# array of a specified type and size. It also shows how to convert the C# array into a C++ std::vector. ```c++ const auto assembly = UnityResolve::Get("assembly.dll | 程序集名称.dll"); const auto pClass = assembly->Get("className | 类名称"); const auto array = UnityResolve::UnityType::Array::New(pClass, size); std::vector cppVector = array.ToVector(); ``` -------------------------------- ### Coordinate Conversion Source: https://github.com/issuimo/unityresolve.hpp/blob/main/README.md Provides functions for converting between world coordinates and screen coordinates using the main camera. Supports conversion in different eye perspectives. ```c++ Camera* pCamera = UnityResolve::UnityType::Camera::GetMain(); Vector3 point = pCamera->WorldToScreenPoint(Vector3, Eye::Left); Vector3 world = pCamera->ScreenToWorldPoint(point, Eye::Left); ``` -------------------------------- ### Set Platform Mode for UnityResolve Source: https://github.com/issuimo/unityresolve.hpp/blob/main/README.md This code snippet shows how to define which platform UnityResolve should target. By setting the appropriate macro (WINDOWS_MODE, ANDROID_MODE, LINUX_MODE) to 1, you can configure the library for the desired operating system. ```C++ #define WINDOWS_MODE 1 // If you need it, change to 1 #define ANDROID_MODE 0 #define LINUX_MODE 0 ``` -------------------------------- ### Attach and Detach C# GC Thread Source: https://github.com/issuimo/unityresolve.hpp/blob/main/README.md These snippets show how to attach and detach the C# Garbage Collector thread using UnityResolve. This is crucial for managing C# objects within the Unity environment. ```C++ // C# GC Attach UnityResolve::ThreadAttach(); // C# GC Detach UnityResolve::ThreadDetach(); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.