Reorganized UnityEngine namespace

Reorganized UnityEngine namespace by splitting headers into individual classes
This commit is contained in:
Jadis0x
2024-06-07 19:07:09 +03:00
parent 0d3675c8cd
commit 0b90598356
26 changed files with 311 additions and 236 deletions

View File

@@ -0,0 +1,8 @@
#include "pch-il2cpp.h"
#include "UnityEngine/Camera.h"
app::Camera* Camera::GetMainCamera()
{
return app::Camera_get_main(nullptr) ? app::Camera_get_main(nullptr) : nullptr;
}

View File

@@ -0,0 +1,29 @@
#include "pch-il2cpp.h"
#include "UnityEngine/GameObject.h"
#include "wrapper.h"
#include <helpers.h>
app::Component* GameObject::GetComponentByName(app::GameObject* go, const char* type)
{
app::Component* component = app::GameObject_GetComponentByName(go, ConvertToSystemString(type), nullptr);
return component ? component : nullptr;
}
app::Component__Array* GameObject::LogComponents(app::GameObject* go)
{
Wrapper obj("UnityEngine.CoreModule.dll");
Il2CppObject* object = obj.find_class("UnityEngine", "Component").get_class();
if (!object) return nullptr;
app::Type* type = reinterpret_cast<app::Type*>(object);
if (!type) return nullptr;
app::Component__Array* __components = app::GameObject_GetComponents(go, type, nullptr);
return __components ? __components : nullptr;
}

View File

@@ -0,0 +1,9 @@
#include "pch-il2cpp.h"
#include "UnityEngine/Input.h"
#include <helpers.h>
float Input::GetAxis(const char* axisName)
{
return app::Input_1_GetAxis(ConvertToSystemString(axisName), nullptr);
}

View File

@@ -0,0 +1,16 @@
#include "pch-il2cpp.h"
#include "UnityEngine/Math.h"
#include <helpers.h>
const char* Math::Vector3::ToString(app::Vector3* v)
{
app::String* str = app::Vector3_ToString(v, nullptr);
return str ? il2cppi_to_string(str).c_str() : "Vector::ToString returned nullptr!\n";
}
const char* Math::Vector3::ToString(app::Vector3 v)
{
return ("x: " + std::to_string(v.x) + " y: " + std::to_string(v.y) + " z: " + std::to_string(v.z)).c_str();
}

View File

@@ -0,0 +1,30 @@
#include "pch-il2cpp.h"
#include "UnityEngine/Object.h"
#include <string>
#include <helpers.h>
const char* Object::GetObjectName(app::Object_1* obj)
{
static std::string name = il2cppi_to_string(app::Object_1_GetName(obj, nullptr));
return name.c_str();
}
app::GameObject__Array* Object::FindGameObjectsWithTag(const char* tag)
{
app::GameObject__Array* go_array_result = app::GameObject_FindGameObjectsWithTag(ConvertToSystemString(tag), nullptr);
return go_array_result ? go_array_result : nullptr;
}
void Object::FindObjectFromInstanceID(int32_t instanceID)
{
}
bool Object::IsNull(app::Object_1* obj)
{
if (obj == nullptr)
return true;
return !app::Object_1_op_Implicit(obj, nullptr);
}

View File

@@ -0,0 +1,19 @@
#include "pch-il2cpp.h"
#include "UnityEngine/Transform.h"
app::Transform* Transform::Get(app::GameObject* go)
{
if (!go || !app::GameObject_get_transform) return nullptr;
app::Transform* __transform = app::GameObject_get_transform(go, nullptr);
return __transform ? __transform : nullptr;
}
app::Vector3 Transform::Position(app::Transform* transform)
{
if (!transform || !app::Transform_get_position) return app::Vector3();
return app::Transform_get_position(transform, nullptr);
}