From 9b7ae3030c219ebd00cb1629e078d66abf1e64f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=81=82=E6=B2=AB?= <1992724048@qq.com> Date: Thu, 29 Aug 2024 13:35:23 +0800 Subject: [PATCH] Update UnityResolve.hpp #23 #21 --- UnityResolve.hpp | 292 +++++++++++++++++++++++------------------------ 1 file changed, 146 insertions(+), 146 deletions(-) diff --git a/UnityResolve.hpp b/UnityResolve.hpp index 5353efd..26e94f1 100644 --- a/UnityResolve.hpp +++ b/UnityResolve.hpp @@ -82,7 +82,7 @@ class UnityResolve final { std::vector classes; [[nodiscard]] auto Get(const std::string& strClass, const std::string& strNamespace = "*", const std::string& strParent = "*") const -> Class* { - + for (const auto pClass : classes) if (strClass == pClass->name && (strNamespace == "*" || pClass->namespaze == strNamespace) && (strParent == "*" || pClass->parent == strParent)) return pClass; return nullptr; } @@ -111,7 +111,7 @@ class UnityResolve final { template auto Get(const std::string& name, const std::vector& args = {}) -> RType* { - + if constexpr (std::is_same_v) for (auto pField : fields) if (pField->name == name) return static_cast(pField); if constexpr (std::is_same_v) for (const auto pField : fields) if (pField->name == name) return reinterpret_cast(pField->offset); if constexpr (std::is_same_v) { @@ -199,7 +199,7 @@ class UnityResolve final { template struct Variable { private: - std::int32_t offset{0}; + std::int32_t offset{ 0 }; public: void Init(const Field* field) { @@ -238,7 +238,7 @@ class UnityResolve final { public: template auto Invoke(Args... args) -> Return { - + Compile(); #if WINDOWS_MODE if (function) return reinterpret_cast(function)(args...); @@ -249,13 +249,13 @@ class UnityResolve final { } auto Compile() -> void { - + if (address && !function && mode_ == Mode::Mono) function = UnityResolve::Invoke("mono_compile_method", address); } template auto RuntimeInvoke(Obj* obj, Args... args) -> Return { - + void* exc{}; void* argArray[sizeof...(Args) + 1]; if (sizeof...(Args) > 0) { @@ -283,7 +283,7 @@ class UnityResolve final { template auto Cast() -> MethodPointer { - + Compile(); if (function) return reinterpret_cast>(function); return nullptr; @@ -291,7 +291,7 @@ class UnityResolve final { template auto Cast(MethodPointer& ptr) -> MethodPointer { - + Compile(); if (function) { ptr = reinterpret_cast>(function); @@ -335,7 +335,7 @@ class UnityResolve final { if (Get("UnityEngine.dll") && (!Get("UnityEngine.CoreModule.dll") || !Get("UnityEngine.PhysicsModule.dll"))) { // 兼容某些游戏 (如生死狙击2) - for (const std::vector names = { "UnityEngine.CoreModule.dll", "UnityEngine.PhysicsModule.dll" }; const auto& name : names) { + for (const std::vector names = { "UnityEngine.CoreModule.dll", "UnityEngine.PhysicsModule.dll" }; const auto & name : names) { const auto ass = Get("UnityEngine.dll"); const auto assembly = new Assembly{ .address = ass->address, .name = name, .file = ass->file, .classes = ass->classes }; UnityResolve::assembly.push_back(assembly); @@ -345,7 +345,7 @@ class UnityResolve final { } #if WINDOWS_MODE || LINUX_MODE /*__cplusplus >= 202002L*/ - static auto DumpToFile(const std::string& path = "./") -> void { + static auto DumpToFile(const std::string path) -> void { std::ofstream io(path + "dump.cs", std::fstream::out); if (!io) return; @@ -1163,12 +1163,12 @@ class UnityResolve final { const auto m_fDist = (x * x) + (y * y) + (z * z) + (w * w); if (const auto m_fTest = x * w - y * z; m_fTest > 0.4995F * m_fDist) { - m_vEuler.x = std::numbers::pi_v * 0.5F; + m_vEuler.x = std::numbers::pi_v *0.5F; m_vEuler.y = 2.F * atan2f(y, x); m_vEuler.z = 0.F; } else if (m_fTest < -0.4995F * m_fDist) { - m_vEuler.x = std::numbers::pi_v * -0.5F; + m_vEuler.x = std::numbers::pi_v *-0.5F; m_vEuler.y = -2.F * atan2f(y, x); m_vEuler.z = 0.F; } @@ -1325,7 +1325,7 @@ class UnityResolve final { struct MonitorData* monitor{ nullptr }; auto GetType() -> CsType* { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("Object", "System")->Get("GetType"); if (method) return method->Invoke(this); @@ -1333,7 +1333,7 @@ class UnityResolve final { } auto ToString() -> String* { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("Object", "System")->Get("ToString"); if (method) return method->Invoke(this); @@ -1341,7 +1341,7 @@ class UnityResolve final { } int GetHashCode() { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("Object", "System")->Get("GetHashCode"); if (method) return method->Invoke(this); @@ -1412,7 +1412,7 @@ class UnityResolve final { struct FieldInfo : public MemberInfo { auto GetIsInitOnly() -> bool { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("FieldInfo", "System.Reflection", "MemberInfo")->Get("get_IsInitOnly"); if (method) return method->Invoke(this); @@ -1420,7 +1420,7 @@ class UnityResolve final { } auto GetIsLiteral() -> bool { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("FieldInfo", "System.Reflection", "MemberInfo")->Get("get_IsLiteral"); if (method) return method->Invoke(this); @@ -1428,7 +1428,7 @@ class UnityResolve final { } auto GetIsNotSerialized() -> bool { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("FieldInfo", "System.Reflection", "MemberInfo")->Get("get_IsNotSerialized"); if (method) return method->Invoke(this); @@ -1436,7 +1436,7 @@ class UnityResolve final { } auto GetIsStatic() -> bool { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("FieldInfo", "System.Reflection", "MemberInfo")->Get("get_IsStatic"); if (method) return method->Invoke(this); @@ -1444,7 +1444,7 @@ class UnityResolve final { } auto GetIsFamily() -> bool { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("FieldInfo", "System.Reflection", "MemberInfo")->Get("get_IsFamily"); if (method) return method->Invoke(this); @@ -1452,7 +1452,7 @@ class UnityResolve final { } auto GetIsPrivate() -> bool { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("FieldInfo", "System.Reflection", "MemberInfo")->Get("get_IsPrivate"); if (method) return method->Invoke(this); @@ -1460,7 +1460,7 @@ class UnityResolve final { } auto GetIsPublic() -> bool { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("FieldInfo", "System.Reflection", "MemberInfo")->Get("get_IsPublic"); if (method) return method->Invoke(this); @@ -1468,7 +1468,7 @@ class UnityResolve final { } auto GetAttributes() -> FieldAttributes { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("FieldInfo", "System.Reflection", "MemberInfo")->Get("get_Attributes"); if (method) return method->Invoke(this); @@ -1476,7 +1476,7 @@ class UnityResolve final { } auto GetMemberType() -> MemberTypes { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("FieldInfo", "System.Reflection", "MemberInfo")->Get("get_MemberType"); if (method) return method->Invoke(this); @@ -1484,7 +1484,7 @@ class UnityResolve final { } auto GetFieldOffset() -> int { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("FieldInfo", "System.Reflection", "MemberInfo")->Get("GetFieldOffset"); if (method) return method->Invoke(this); @@ -1493,7 +1493,7 @@ class UnityResolve final { template auto GetValue(Object* object) -> T { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("FieldInfo", "System.Reflection", "MemberInfo")->Get("GetValue"); if (method) return method->Invoke(this, object); @@ -1502,7 +1502,7 @@ class UnityResolve final { template auto SetValue(Object* object, T value) -> void { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("FieldInfo", "System.Reflection", "MemberInfo")->Get("SetValue", { "System.Object", "System.Object" }); if (method) return method->Invoke(this, object, value); @@ -1511,7 +1511,7 @@ class UnityResolve final { struct CsType { auto FormatTypeName() -> String* { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("Type", "System", "MemberInfo")->Get("FormatTypeName"); if (method) return method->Invoke(this); @@ -1519,7 +1519,7 @@ class UnityResolve final { } auto GetFullName() -> String* { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("Type", "System", "MemberInfo")->Get("get_FullName"); if (method) return method->Invoke(this); @@ -1527,7 +1527,7 @@ class UnityResolve final { } auto GetNamespace() -> String* { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("Type", "System", "MemberInfo")->Get("get_Namespace"); if (method) return method->Invoke(this); @@ -1535,7 +1535,7 @@ class UnityResolve final { } auto GetIsSerializable() -> bool { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("Type", "System", "MemberInfo")->Get("get_IsSerializable"); if (method) return method->Invoke(this); @@ -1543,7 +1543,7 @@ class UnityResolve final { } auto GetContainsGenericParameters() -> bool { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("Type", "System", "MemberInfo")->Get("get_ContainsGenericParameters"); if (method) return method->Invoke(this); @@ -1551,7 +1551,7 @@ class UnityResolve final { } auto GetIsVisible() -> bool { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("Type", "System", "MemberInfo")->Get("get_IsVisible"); if (method) return method->Invoke(this); @@ -1559,7 +1559,7 @@ class UnityResolve final { } auto GetIsNested() -> bool { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("Type", "System", "MemberInfo")->Get("get_IsNested"); if (method) return method->Invoke(this); @@ -1567,7 +1567,7 @@ class UnityResolve final { } auto GetIsArray() -> bool { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("Type", "System", "MemberInfo")->Get("get_IsArray"); if (method) return method->Invoke(this); @@ -1575,7 +1575,7 @@ class UnityResolve final { } auto GetIsByRef() -> bool { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("Type", "System", "MemberInfo")->Get("get_IsByRef"); if (method) return method->Invoke(this); @@ -1583,7 +1583,7 @@ class UnityResolve final { } auto GetIsPointer() -> bool { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("Type", "System", "MemberInfo")->Get("get_IsPointer"); if (method) return method->Invoke(this); @@ -1591,7 +1591,7 @@ class UnityResolve final { } auto GetIsConstructedGenericType() -> bool { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("Type", "System", "MemberInfo")->Get("get_IsConstructedGenericType"); if (method) return method->Invoke(this); @@ -1599,7 +1599,7 @@ class UnityResolve final { } auto GetIsGenericParameter() -> bool { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("Type", "System", "MemberInfo")->Get("get_IsGenericParameter"); if (method) return method->Invoke(this); @@ -1607,7 +1607,7 @@ class UnityResolve final { } auto GetIsGenericMethodParameter() -> bool { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("Type", "System", "MemberInfo")->Get("get_IsGenericMethodParameter"); if (method) return method->Invoke(this); @@ -1615,7 +1615,7 @@ class UnityResolve final { } auto GetIsGenericType() -> bool { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("Type", "System", "MemberInfo")->Get("get_IsGenericType"); if (method) return method->Invoke(this); @@ -1623,7 +1623,7 @@ class UnityResolve final { } auto GetIsGenericTypeDefinition() -> bool { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("Type", "System", "MemberInfo")->Get("get_IsGenericTypeDefinition"); if (method) return method->Invoke(this); @@ -1631,7 +1631,7 @@ class UnityResolve final { } auto GetIsSZArray() -> bool { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("Type", "System", "MemberInfo")->Get("get_IsSZArray"); if (method) return method->Invoke(this); @@ -1639,7 +1639,7 @@ class UnityResolve final { } auto GetIsVariableBoundArray() -> bool { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("Type", "System", "MemberInfo")->Get("get_IsVariableBoundArray"); if (method) return method->Invoke(this); @@ -1647,7 +1647,7 @@ class UnityResolve final { } auto GetHasElementType() -> bool { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("Type", "System", "MemberInfo")->Get("get_HasElementType"); if (method) return method->Invoke(this); @@ -1655,7 +1655,7 @@ class UnityResolve final { } auto GetIsAbstract() -> bool { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("Type", "System", "MemberInfo")->Get("get_IsAbstract"); if (method) return method->Invoke(this); @@ -1663,7 +1663,7 @@ class UnityResolve final { } auto GetIsSealed() -> bool { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("Type", "System", "MemberInfo")->Get("get_IsSealed"); if (method) return method->Invoke(this); @@ -1671,7 +1671,7 @@ class UnityResolve final { } auto GetIsClass() -> bool { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("Type", "System", "MemberInfo")->Get("get_IsClass"); if (method) return method->Invoke(this); @@ -1679,7 +1679,7 @@ class UnityResolve final { } auto GetIsNestedAssembly() -> bool { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("Type", "System", "MemberInfo")->Get("get_IsNestedAssembly"); if (method) return method->Invoke(this); @@ -1687,7 +1687,7 @@ class UnityResolve final { } auto GetIsNestedPublic() -> bool { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("Type", "System", "MemberInfo")->Get("get_IsNestedPublic"); if (method) return method->Invoke(this); @@ -1695,7 +1695,7 @@ class UnityResolve final { } auto GetIsNotPublic() -> bool { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("Type", "System", "MemberInfo")->Get("get_IsNotPublic"); if (method) return method->Invoke(this); @@ -1703,7 +1703,7 @@ class UnityResolve final { } auto GetIsPublic() -> bool { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("Type", "System", "MemberInfo")->Get("get_IsPublic"); if (method) return method->Invoke(this); @@ -1711,7 +1711,7 @@ class UnityResolve final { } auto GetIsExplicitLayout() -> bool { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("Type", "System", "MemberInfo")->Get("get_IsExplicitLayout"); if (method) return method->Invoke(this); @@ -1719,7 +1719,7 @@ class UnityResolve final { } auto GetIsCOMObject() -> bool { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("Type", "System", "MemberInfo")->Get("get_IsCOMObject"); if (method) return method->Invoke(this); @@ -1727,7 +1727,7 @@ class UnityResolve final { } auto GetIsContextful() -> bool { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("Type", "System", "MemberInfo")->Get("get_IsContextful"); if (method) return method->Invoke(this); @@ -1735,7 +1735,7 @@ class UnityResolve final { } auto GetIsCollectible() -> bool { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("Type", "System", "MemberInfo")->Get("get_IsCollectible"); if (method) return method->Invoke(this); @@ -1743,7 +1743,7 @@ class UnityResolve final { } auto GetIsEnum() -> bool { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("Type", "System", "MemberInfo")->Get("get_IsEnum"); if (method) return method->Invoke(this); @@ -1751,7 +1751,7 @@ class UnityResolve final { } auto GetIsMarshalByRef() -> bool { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("Type", "System", "MemberInfo")->Get("get_IsMarshalByRef"); if (method) return method->Invoke(this); @@ -1759,7 +1759,7 @@ class UnityResolve final { } auto GetIsPrimitive() -> bool { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("Type", "System", "MemberInfo")->Get("get_IsPrimitive"); if (method) return method->Invoke(this); @@ -1767,7 +1767,7 @@ class UnityResolve final { } auto GetIsValueType() -> bool { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("Type", "System", "MemberInfo")->Get("get_IsValueType"); if (method) return method->Invoke(this); @@ -1775,7 +1775,7 @@ class UnityResolve final { } auto GetIsSignatureType() -> bool { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("Type", "System", "MemberInfo")->Get("get_IsSignatureType"); if (method) return method->Invoke(this); @@ -1783,9 +1783,9 @@ class UnityResolve final { } auto GetField(const std::string& name, const BindingFlags flags = static_cast(static_cast(BindingFlags::Instance) | static_cast(BindingFlags::Static) | static_cast(BindingFlags::Public))) -> FieldInfo* { - + static Method* method; - if (!method) method = Get("mscorlib.dll")->Get("Type", "System", "MemberInfo")->Get("GetField", { "System.String name" }); + if (!method) method = Get("mscorlib.dll")->Get("Type", "System", "MemberInfo")->Get("GetField", { "System.String name", "System.Reflection.BindingFlags" }); if (method) return method->Invoke(this, String::New(name), flags); return nullptr; } @@ -1807,13 +1807,13 @@ class UnityResolve final { auto operator==(const std::wstring& newString) const -> bool { return Equals(newString); } auto Clear() -> void { - + memset(m_firstChar, 0, m_stringLength); m_stringLength = 0; } [[nodiscard]] auto Equals(const std::wstring& newString) const -> bool { - + if (newString.size() != m_stringLength) return false; if (std::memcmp(newString.data(), m_firstChar, m_stringLength) != 0) return false; return true; @@ -1833,7 +1833,7 @@ class UnityResolve final { }*bounds{ nullptr }; std::uintptr_t max_length{ 0 }; - T** vector {}; + T** vector{}; auto GetData() -> uintptr_t { return reinterpret_cast(&vector); } @@ -1917,14 +1917,14 @@ class UnityResolve final { auto operator[](const unsigned int m_uIndex) -> Type& { return pList->At(m_uIndex); } auto Add(Type pDate) -> void { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("List`1")->Get("Add"); if (method) return method->Invoke(this, pDate); } auto Remove(Type pDate) -> bool { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("List`1")->Get("Remove"); if (method) return method->Invoke(this, pDate); @@ -1932,21 +1932,21 @@ class UnityResolve final { } auto RemoveAt(int index) -> void { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("List`1")->Get("RemoveAt"); if (method) return method->Invoke(this, index); } auto ForEach(void(*action)(Type pDate)) -> void { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("List`1")->Get("ForEach"); if (method) return method->Invoke(this, action); } auto GetRange(int index, int count) -> List* { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("List`1")->Get("GetRange"); if (method) return method->Invoke(this, index, count); @@ -1954,14 +1954,14 @@ class UnityResolve final { } auto Clear() -> void { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("List`1")->Get("Clear"); if (method) return method->Invoke(this); } auto Sort(int (*comparison)(Type* pX, Type* pY)) -> void { - + static Method* method; if (!method) method = Get("mscorlib.dll")->Get("List`1")->Get("Sort", { "*" }); if (method) return method->Invoke(this, comparison); @@ -2020,7 +2020,7 @@ class UnityResolve final { void* m_CachedPtr; auto GetName() -> String* { - + static Method* method; if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Object")->Get("get_name"); if (method) return method->Invoke(this); @@ -2028,7 +2028,7 @@ class UnityResolve final { } auto ToString() -> String* { - + static Method* method; if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Object")->Get("ToString"); if (method) return method->Invoke(this); @@ -2061,7 +2061,7 @@ class UnityResolve final { struct Component : public UnityObject { auto GetTransform() -> Transform* { - + static Method* method; if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Component")->Get("get_transform"); if (method) return method->Invoke(this); @@ -2069,7 +2069,7 @@ class UnityResolve final { } auto GetGameObject() -> GameObject* { - + static Method* method; if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Component")->Get("get_gameObject"); if (method) return method->Invoke(this); @@ -2077,7 +2077,7 @@ class UnityResolve final { } auto GetTag() -> String* { - + static Method* method; if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Component")->Get("get_tag"); if (method) return method->Invoke(this); @@ -2086,7 +2086,7 @@ class UnityResolve final { template auto GetComponentsInChildren() -> std::vector { - + static Method* method; if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Component")->Get("GetComponentsInChildren"); if (method) return method->Invoke*>(this)->ToVector(); @@ -2096,7 +2096,7 @@ class UnityResolve final { template auto GetComponentsInChildren(Class* pClass) -> std::vector { static Method* method; - + if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Component")->Get("GetComponentsInChildren", { "System.Type" }); if (method) return method->Invoke*>(this, pClass->GetType())->ToVector(); return {}; @@ -2114,7 +2114,7 @@ class UnityResolve final { auto GetComponents(Class* pClass) -> std::vector { static Method* method; static void* obj; - + if (!method || !obj) { method = Get("UnityEngine.CoreModule.dll")->Get("Component")->Get("GetComponents", { "System.Type" }); obj = pClass->GetType(); @@ -2135,7 +2135,7 @@ class UnityResolve final { auto GetComponentsInParent(Class* pClass) -> std::vector { static Method* method; static void* obj; - + if (!method || !obj) { method = Get("UnityEngine.CoreModule.dll")->Get("Component")->Get("GetComponentsInParent", { "System.Type" }); obj = pClass->GetType(); @@ -2210,7 +2210,7 @@ class UnityResolve final { } auto GetDepth() -> float { - + static Method* method; if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Camera")->Get("get_depth"); if (method) return method->Invoke(this); @@ -2218,21 +2218,21 @@ class UnityResolve final { } auto SetDepth(const float depth) -> void { - + static Method* method; if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Camera")->Get("set_depth", { "*" }); if (method) return method->Invoke(this, depth); } auto SetFoV(const float fov) -> void { - + static Method* method_fieldOfView; if (!method_fieldOfView) method_fieldOfView = Get("UnityEngine.CoreModule.dll")->Get("Camera")->Get("set_fieldOfView", { "*" }); if (method_fieldOfView) return method_fieldOfView->Invoke(this, fov); } auto GetFoV() -> float { - + static Method* method_fieldOfView; if (!method_fieldOfView) method_fieldOfView = Get("UnityEngine.CoreModule.dll")->Get("Camera")->Get("get_fieldOfView"); if (method_fieldOfView) return method_fieldOfView->Invoke(this); @@ -2240,7 +2240,7 @@ class UnityResolve final { } auto WorldToScreenPoint(const Vector3& position, const Eye eye = Eye::Mono) -> Vector3 { - + static Method* method; if (!method) { if (mode_ == Mode::Mono) method = Get("UnityEngine.CoreModule.dll")->Get("Camera")->Get("WorldToScreenPoint_Injected"); @@ -2256,7 +2256,7 @@ class UnityResolve final { } auto ScreenToWorldPoint(const Vector3& position, const Eye eye = Eye::Mono) -> Vector3 { - + static Method* method; if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Camera")->Get(mode_ == Mode::Mono ? "ScreenToWorldPoint_Injected" : "ScreenToWorldPoint"); if (mode_ == Mode::Mono && method) { @@ -2269,7 +2269,7 @@ class UnityResolve final { } auto CameraToWorldMatrix() -> Matrix4x4 { - + static Method* method; if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Camera")->Get(mode_ == Mode::Mono ? "get_cameraToWorldMatrix_Injected" : "get_cameraToWorldMatrix"); if (mode_ == Mode::Mono && method) { @@ -2285,7 +2285,7 @@ class UnityResolve final { struct Transform : Component { auto GetPosition() -> Vector3 { static Method* method; - + if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Transform")->Get("get_position_Injected"); const Vector3 vec3{}; method->Invoke(this, &vec3); @@ -2294,14 +2294,14 @@ class UnityResolve final { auto SetPosition(const Vector3& position) -> void { static Method* method; - + if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Transform")->Get("set_position_Injected"); return method->Invoke(this, &position); } auto GetRight() -> Vector3 { static Method* method; - + if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Transform")->Get("get_right"); if (method) return method->Invoke(this); return {}; @@ -2309,14 +2309,14 @@ class UnityResolve final { auto SetRight(const Vector3& value) -> void { static Method* method; - + if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Transform")->Get("set_right"); if (method) return method->Invoke(this, value); } auto GetUp() -> Vector3 { static Method* method; - + if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Transform")->Get("get_up"); if (method) return method->Invoke(this); return {}; @@ -2324,14 +2324,14 @@ class UnityResolve final { auto SetUp(const Vector3& value) -> void { static Method* method; - + if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Transform")->Get("set_up"); if (method) return method->Invoke(this, value); } auto GetForward() -> Vector3 { static Method* method; - + if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Transform")->Get("get_forward"); if (method) return method->Invoke(this); return {}; @@ -2339,14 +2339,14 @@ class UnityResolve final { auto SetForward(const Vector3& value) -> void { static Method* method; - + if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Transform")->Get("set_forward"); if (method) return method->Invoke(this, value); } auto GetRotation() -> Quaternion { static Method* method; - + if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Transform")->Get(mode_ == Mode::Mono ? "get_rotation_Injected" : "get_rotation"); if (mode_ == Mode::Mono && method) { const Quaternion vec3{}; @@ -2359,7 +2359,7 @@ class UnityResolve final { auto SetRotation(const Quaternion& position) -> void { static Method* method; - + if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Transform")->Get(mode_ == Mode::Mono ? "set_rotation_Injected" : "set_rotation"); if (mode_ == Mode::Mono && method) return method->Invoke(this, &position); if (method) return method->Invoke(this, position); @@ -2367,7 +2367,7 @@ class UnityResolve final { auto GetLocalPosition() -> Vector3 { static Method* method; - + if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Transform")->Get(mode_ == Mode::Mono ? "get_localPosition_Injected" : "get_localPosition"); if (mode_ == Mode::Mono && method) { const Vector3 vec3{}; @@ -2380,7 +2380,7 @@ class UnityResolve final { auto SetLocalPosition(const Vector3& position) -> void { static Method* method; - + if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Transform")->Get(mode_ == Mode::Mono ? "set_localPosition_Injected" : "set_localPosition"); if (mode_ == Mode::Mono && method) return method->Invoke(this, &position); if (method) return method->Invoke(this, position); @@ -2388,7 +2388,7 @@ class UnityResolve final { auto GetLocalRotation() -> Quaternion { static Method* method; - + if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Transform")->Get(mode_ == Mode::Mono ? "get_localRotation_Injected" : "get_localRotation"); if (mode_ == Mode::Mono && method) { const Quaternion vec3{}; @@ -2401,7 +2401,7 @@ class UnityResolve final { auto SetLocalRotation(const Quaternion& position) -> void { static Method* method; - + if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Transform")->Get(mode_ == Mode::Mono ? "set_localRotation_Injected" : "set_localRotation"); if (mode_ == Mode::Mono && method) return method->Invoke(this, &position); if (method) return method->Invoke(this, position); @@ -2409,7 +2409,7 @@ class UnityResolve final { auto GetLocalScale() -> Vector3 { static Method* method; - + if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Transform")->Get("get_localScale_Injected"); const Vector3 vec3{}; method->Invoke(this, &vec3); @@ -2418,7 +2418,7 @@ class UnityResolve final { auto SetLocalScale(const Vector3& position) -> void { static Method* method; - + if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Transform")->Get(mode_ == Mode::Mono ? "set_localScale_Injected" : "set_localScale"); if (mode_ == Mode::Mono && method) return method->Invoke(this, &position); if (method) return method->Invoke(this, position); @@ -2426,7 +2426,7 @@ class UnityResolve final { auto GetChildCount() -> int { static Method* method; - + if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Transform")->Get("get_childCount"); if (method) return method->Invoke(this); return 0; @@ -2434,7 +2434,7 @@ class UnityResolve final { auto GetChild(const int index) -> Transform* { static Method* method; - + if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Transform")->Get("GetChild"); if (method) return method->Invoke(this, index); return nullptr; @@ -2442,7 +2442,7 @@ class UnityResolve final { auto GetRoot() -> Transform* { static Method* method; - + if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Transform")->Get("GetRoot"); if (method) return method->Invoke(this); return nullptr; @@ -2450,7 +2450,7 @@ class UnityResolve final { auto GetParent() -> Transform* { static Method* method; - + if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Transform")->Get("GetParent"); if (method) return method->Invoke(this); return nullptr; @@ -2458,7 +2458,7 @@ class UnityResolve final { auto GetLossyScale() -> Vector3 { static Method* method; - + if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Transform")->Get(mode_ == Mode::Mono ? "get_lossyScale_Injected" : "get_lossyScale"); if (mode_ == Mode::Mono && method) { const Vector3 vec3{}; @@ -2471,7 +2471,7 @@ class UnityResolve final { auto TransformPoint(const Vector3& position) -> Vector3 { static Method* method; - + if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Transform")->Get(mode_ == Mode::Mono ? "TransformPoint_Injected" : "TransformPoint"); if (mode_ == Mode::Mono && method) { const Vector3 vec3{}; @@ -2484,14 +2484,14 @@ class UnityResolve final { auto LookAt(const Vector3& worldPosition) -> void { static Method* method; - + if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Transform")->Get("LookAt", { "Vector3" }); if (method) return method->Invoke(this, worldPosition); } auto Rotate(const Vector3& eulers) -> void { static Method* method; - + if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Transform")->Get("Rotate", { "Vector3" }); if (method) return method->Invoke(this, eulers); } @@ -2524,7 +2524,7 @@ class UnityResolve final { auto GetActive() -> bool { static Method* method; - + if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("GameObject")->Get("get_active"); if (method) return method->Invoke(this); return false; @@ -2532,14 +2532,14 @@ class UnityResolve final { auto SetActive(const bool value) -> void { static Method* method; - + if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("GameObject")->Get("set_active"); if (method) return method->Invoke(this, value); } auto GetActiveSelf() -> bool { static Method* method; - + if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("GameObject")->Get("get_activeSelf"); if (method) return method->Invoke(this); return false; @@ -2547,7 +2547,7 @@ class UnityResolve final { auto GetActiveInHierarchy() -> bool { static Method* method; - + if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("GameObject")->Get("get_activeInHierarchy"); if (method) return method->Invoke(this); return false; @@ -2555,7 +2555,7 @@ class UnityResolve final { auto GetIsStatic() -> bool { static Method* method; - + if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("GameObject")->Get("get_isStatic"); if (method) return method->Invoke(this); return false; @@ -2563,14 +2563,14 @@ class UnityResolve final { auto GetTransform() -> Transform* { static Method* method; - + if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("GameObject")->Get("get_transform"); if (method) return method->Invoke(this); return nullptr; } auto GetTag() -> String* { - + static Method* method; if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("GameObject")->Get("get_tag"); if (method) return method->Invoke(this); @@ -2579,7 +2579,7 @@ class UnityResolve final { template auto GetComponent() -> T { - + static Method* method; if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("GameObject")->Get("GetComponent"); if (method) return method->Invoke(this); @@ -2588,7 +2588,7 @@ class UnityResolve final { template auto GetComponent(Class* type) -> T { - + static Method* method; if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("GameObject")->Get("GetComponent", { "System.Type" }); if (method) return method->Invoke(this, type->GetType()); @@ -2597,7 +2597,7 @@ class UnityResolve final { template auto GetComponentInChildren(Class* type) -> T { - + static Method* method; if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("GameObject")->Get("GetComponentInChildren", { "System.Type" }); if (method) return method->Invoke(this, type->GetType()); @@ -2606,7 +2606,7 @@ class UnityResolve final { template auto GetComponentInParent(Class* type) -> T { - + static Method* method; if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("GameObject")->Get("GetComponentInParent", { "System.Type" }); if (method) return method->Invoke(this, type->GetType()); @@ -2615,7 +2615,7 @@ class UnityResolve final { template auto GetComponents(Class* type, bool useSearchTypeAsArrayReturnType = false, bool recursive = false, bool includeInactive = true, bool reverse = false, List* resultList = nullptr) -> std::vector { - + static Method* method; if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("GameObject")->Get("GetComponentsInternal"); if (method) return method->Invoke*>(this, type->GetType(), useSearchTypeAsArrayReturnType, recursive, includeInactive, reverse, resultList)->ToVector(); @@ -2684,7 +2684,7 @@ class UnityResolve final { struct Collider : Component { auto GetBounds() -> Bounds { - + static Method* method; if (!method) method = Get("UnityEngine.PhysicsModule.dll")->Get("Collider")->Get("get_bounds_Injected"); if (method) { @@ -2698,7 +2698,7 @@ class UnityResolve final { struct Mesh : UnityObject { auto GetBounds() -> Bounds { - + static Method* method; if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Mesh")->Get("get_bounds_Injected"); if (method) { @@ -2758,7 +2758,7 @@ class UnityResolve final { struct Renderer : Component { auto GetBounds() -> Bounds { - + static Method* method; if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Renderer")->Get("get_bounds_Injected"); if (method) { @@ -2772,7 +2772,7 @@ class UnityResolve final { struct Behaviour : public Component { auto GetEnabled() -> bool { - + static Method* method; if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Behaviour")->Get("get_enabled"); if (method) return method->Invoke(this); @@ -2780,7 +2780,7 @@ class UnityResolve final { } auto SetEnabled(const bool value) -> void { - + static Method* method; if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Behaviour")->Get("set_enabled"); if (method) return method->Invoke(this, value); @@ -2880,7 +2880,7 @@ class UnityResolve final { auto GetBoneTransform(const HumanBodyBones humanBoneId) -> Transform* { static Method* method; - + if (!method) method = Get("UnityEngine.AnimationModule.dll")->Get("Animator")->Get("GetBoneTransform"); if (method) return method->Invoke(this, humanBoneId); return nullptr; @@ -2923,21 +2923,21 @@ class UnityResolve final { } }; - struct Screen { - static auto get_width() -> Int32 { - static Method *method; - if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Screen")->Get("get_width"); - if (method) return method->Invoke(); - return 0; - } - - static auto get_height() -> Int32 { - static Method *method; - if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Screen")->Get("get_height"); - if (method) return method->Invoke(); - return 0; - } - }; + struct Screen { + static auto get_width() -> Int32 { + static Method* method; + if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Screen")->Get("get_width"); + if (method) return method->Invoke(); + return 0; + } + + static auto get_height() -> Int32 { + static Method* method; + if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Screen")->Get("get_height"); + if (method) return method->Invoke(); + return 0; + } + }; template static auto Invoke(void* address, Args... args) -> Return {